what is the script for an exit popup?

by 27 replies
46
Hello warriors,

I always see sites that when you click them away you get a popup that asked you if you really want to leave and if you press no you go to a special offer. I really want this on my website but I have no idea what this script is so could anybody help me? please?
#programming #exit #popup #script
  • Code:
    <script language="javascript">
    window.onbeforeunload = function() {return '1';}
    </script>
    • [ 2 ] Thanks
    • [1] reply

    • Thank you Mr. phpg .. Great script ..
  • Thank you this really helped me
    • [1] reply
    • Do you also know how I can redirect them to another url when they click cancel? And how people who click on a link in the page or the buy now button don't get this popup?
      • [1] reply
  • If that doesn't work for you as is, then there is something on your page conflicting with this script, so you'd better tell exact url where you are going to put it.
    • [1] reply
  • Thanks it works
  • Is this script worth using? Won't it get blocked?
  • You can learn more Javascript in W3Schools
  • [DELETED]
  • JS redirects can be blocked by some browsers (and/or some extensions). I think some versions of IE might have an issue with it (or might cause some issues in the future).. I know that the php script (exitredirect) is more or less useless if they are using IE..

    I think the most effective way of presenting exit offers is displaying a hidden div, and hiding the original pages content, onBeforeUnload that is populated with your exit redirect URL. That way there is no navigation taking place...

    One of the reasons for this, is that the user can see the exit offer (in most browsers) before even before clicking the confirm box (making the decision to stay or go). I found that I get a much higher success rate on my exit offers this way.

    I actually have a wordpress plugin that i wrote that does this. i can put up as a WSO if you all are interested...

    If you are interested Let me know

    jQuery is also really effective for exit offers. And once the script is written it requires less knowledge of html to make it work...

    If anyone wants any code samples of any of these, Let me know or PM me
  • [DELETED]
    • [ 1 ] Thanks
  • Ok. Here is a exit popup script I found on "Another Forum"

    Code:
    <script type="text/javascript" language="javascript"> 
    var areYouReallySure = false;
    var internalLink = false;
    function areYouSure() {
    if (!areYouReallySure && !internalLink) {
    areYouReallySure = true;
    location.href="REDIRECT URL HERE"
    
    return "*****************************************************nnWait! nnMaybe You're not Interested In My Report , But What About a Chance To Work With Me DIRECTLY? Remember, You're Simply Requesting Information. Also, You Will NEVER Get Spammed From Me!nnWhy Let This Chance Pass You By?nnOn The Next Page Enter Your Name, Email & Phone. I Will Call You PERSONALLY!  nnCLICK CANCEL TO TAKE THE SPECIAL OFFERnn*****************************************************";
    }
    }
    window.onbeforeunload = areYouSure;
    </script>
    The thing is when someone tries to leave the page, everything works great. The PROBLEM is even when someone fills out the optin form on the page, the script sees the user as leaving & the popup opens. Any thoughts on avoiding this?
  • [DELETED]
  • [DELETED]
    • [1] reply
  • I'm just not sure why when someone opt's in, they still get the popup. Does this happen on your script also?
    • [1] reply
    • Not on my pluggin, the pluggin automatically appends javascript to prevent the exit pop if a visitor follows a call to action.

      Not sure if the script i copied to forum has that in it or not.. i certainly have a version of it somewhere...

      Let me know if it doesn't, in the standalone script i wrote, the links have:
      onClick="dontpop();"

      and forms have onSubmit="dontpop();"

      Then i have that function in the script which disables the pop.
  • Do we have to upload in PHP file or HTML file... will it work in both one..
  • Theres a few WP plugins for POP UPS. Most PHP scripts are buggy with no direction.

    Guillermo-
  • PHP Code:
    function PopIt() 
    {          return 
    'Are you sure you want to leave?';     }     
    function 
    UnloadIt() 
    {         
    window.opener.nowDoThisOpener("pass this variable along too");     } 
         $(
    document).ready(function() {         //set the function defining what should be done BEFORE unloading         window.onbeforeunload = PopIt;         //set the function defining what should be done ON unloading         window.onunload = UnloadIt;         //set all links to disable both of these on click         $('a').click(function()
    {              window.onbeforeunload null;             window.onunload=null;   
     });     }); 
  • [DELETED]
  • I also have the same questions as you. Thank you for answering
  • Hello Warriors,

    In jQuery exit pop-up is:

    <script type="text/javascript">

    $(document).ready(function() {

    $(document).mousemove(function(e) {

    $('#exitpopup').css('left', (window.innerWidth/2 - $('#exitpopup').width()/2));
    $('#exitpopup').css('top', (window.innerHeight/2 - $('#exitpopup').height()/2));

    if(e.pageY <= 5)
    {

    // Show the exit popup
    $('#exitpopup_bg').fadeIn();
    $('#exitpopup').fadeIn();
    }

    });

    $('#exitpopup_bg').click(function(){
    $('#exitpopup_bg').fadeOut();
    $('#exitpopup').slideUp();
    });

    });
    </script>

    <style type="text/css">

    #exitpopup
    {
    text-align:center;
    }

    #exitpopup h1
    {
    margin-top:0px;
    padding-top:0px;

    }

    #exitpopup p
    {
    text-align:left;
    }

    </style>



    <div style="display: none; width:100%; height:100%; position:fixed; background:#000000; opacity: .8; filter:alpha(opacity=0.8); z-index:999998;" id="exitpopup_bg">

    </div>
    <div style="width:670px; height:450px; margin:0px auto; display:none; position:fixed; color:#ffffff; padding:20px; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; z-index:999999; background:rgb(20, 20, 20); background:rgba(0, 0, 0, 0.8);" id="exitpopup">
    <h1>Wait!!! Before you go...</h1>
    <p>Hello warriors this is the best answer for you<br /><br />

    This is the best alternative for your question</p>
    <a href="#"><img src="letmeinnow.png" style="width:568px; height:190px" border="0" style="border:0px; margin:0px auto;" /></a>

    </div>

Next Topics on Trending Feed

  • 46

    Hello warriors, I always see sites that when you click them away you get a popup that asked you if you really want to leave and if you press no you go to a special offer. I really want this on my website but I have no idea what this script is so could anybody help me? please?