views:

29

answers:

3

Hi Everyone,

I working on a website, but here now I want a popup window should open anytime when I leave the page / close the page, like this : http://www.ultimateexitpopup.com.

Can someone let me know both script and HTML code for this please?

Regards Balkar

A: 

Try this code in your main file:

window.onunload = function(){
  window.open('path to popup file', 'width="500", height="500"');
};
Sarfraz
A: 

Hi, this should be enough.

<script type='text/javascript'>
<!--
function ExitPop() {
    return "*****************************************************\n\nWAIT! -- \n                                 \n                                \n             XXXX       XXXX XXXX       XXXX\n              XXXX     XXXX   XXXX     XXXX\n               XXXX   XXXX     XXXX   XXXX\n                XXXX XXXX       XXXX XXXX\n                 XXXXXXX         XXXXXXX\n                   XXXXX             XXXXX\n                XXXXXXX          XXXXXXX\n               XXXX XXXX       XXXX XXXX\n               XXXX    XXXX    XXXX   XXXX\n              XXXX     XXXX   XXXX     XXXX\n             XXXX       XXXX XXXX       XXXX\n             \n             \n             \n              -- Click the CANCEL button Now!\n\n*****************************************************"
}
// -->
</script>
<SCRIPT LANGUAGE = "JavaScript">
<!--
window.onbeforeunload = ExitPop;
// -->
</SCRIPT>

By the way, using the onbeforeunload event is not really nice (and I'm not really sure if it's compatible across all the browsers). If you can, you should avoid using it.

Karasutengu