Pop Up warning before leaving a page

Pop Up warning before leaving a page

We sometimes need to have a pop-up warning message displayed before redirecting to a different page.
divider

We sometimes need to have a pop-up warning message displayed before redirecting to a different page.

This is especially handy when you are updating a record and the user needs to do something on a different page before he/she can continue.

I am always forgetting the syntax, so I am adding it here for my own reference. (And everyone else's.)

Lets say you have a graphic link like this:

<a href="gallery_list.php"><img src="../back/images/add2.png" alt="Add Gallery" width="16" height="16" border="0"></a>

To add the pop-up warning change the link to this.

<a href="gallery_list.php" onclick="return confirm('<?php echo NXT_getResource("Are you sure?"); ?>');"><img src="../back/images/add2.png" alt="Add Gallery" width="16" height="16" border="0"></a>

Obviously you can change the confirm('message') to whatever you like.

Leaving the NXT_getResourse... message, your site will automatically make use of the built-in multilingual support if you use it.

Written by:  - 10 Jun, 2010