Skip to content
WJunction - Webmaster Forum

leave this page/stay on page feature

Status
Not open for further replies.
sometimes we come across certain websites that ask with a popup window

that you want to stay on the site or leave this page.


could someone tell how to implement this on a WP bog?
version: 3.2.1
 

5 comments

Use javascript's window.onbeforeunload event

Read about it here: https://developer.mozilla.org/en/DOM/window.onbeforeunload

Sample code:
PHP:
<script type="text/javascript">
    window.onbeforeunload = iamexiting;
    function iamexiting(e) {
        e = e || window.event;
        // For IE and Firefox prior to version 4
        if (e) {
            e.returnValue = 'U noez close teh browser or data lost :(';
        }
        return 'U noez close teh browser or data lost :(';
    }
</script>
Just add that code in the page
 
15393807606d7c56d8ca56609a7060cd.jpg


i got this from Facebook
will it be same or something like this ?
 
Status
Not open for further replies.

About the author

champ_007_bond
Banned · Joined
499
Messages
69
Reactions
28
Points

Advertise on WJunction

Reach 1000's of webmasters, hosts & affiliates. Banner & sponsored-thread slots available.

Contact us
Back
Top Bottom