Exit Popup in Wordpress

Discussion in 'HTML & Website Design' started by acepsdr, Aug 26, 2008.

  1. #1
    I put this code in Body Tag: <body onUnload=popup()>

    But I have problem every open a page, always show the popup too. I want show that popup if exit/close main window (main page).
     
    acepsdr, Aug 26, 2008 IP
  2. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #2
    Thats simple, just use a cookie based Javascript like this >

     <script LANGUAGE="JavaScript"> 
     <!-- Begin var expDays = 1; // number of days the cookie should last 
    var page = "yourpage.htm"; //Popup page
    var windowprops = "width=280,height=320,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no"; 
    function GetCookie (name) { var arg = name + "="; var alen = arg.length; 
    var clen = document.cookie.length; var i = 0; while (i < clen) { var j = i 
    + alen; if (document.cookie.substring(i, j) == arg) return getCookieVal (j); i 
    = document.cookie.indexOf(" ", i) + 1; if (i == 0) break; } return null; 
    } function SetCookie (name, value) { var argv = SetCookie.arguments; var argc 
    = SetCookie.arguments.length; var expires = (argc > 2) ? argv[2] : null; var 
    path = (argc > 3) ? argv[3] : null; var domain = (argc > 4) ? argv[4] : 
    null; var secure = (argc > 5) ? argv[5] : false; document.cookie = name + "=" 
    + escape (value) + ((expires == null) ? "" : ("; expires=" 
    + expires.toGMTString())) + ((path == null) ? "" : ("; path=" 
    + path)) + ((domain == null) ? "" : ("; domain=" + domain)) 
    + ((secure == true) ? "; secure" : ""); } function DeleteCookie 
    (name) { var exp = new Date(); exp.setTime (exp.getTime() - 1); var cval = GetCookie 
    (name); document.cookie = name + "=" + cval + "; expires=" 
    + exp.toGMTString(); } var exp = new Date(); exp.setTime(exp.getTime() + (expDays*24*60*60*1000)); 
    function amt(){ var count = GetCookie('count') if(count == null) { SetCookie('count','1') 
    return 1 } else { var newcount = parseInt(count) + 1; DeleteCookie('count') SetCookie('count',newcount,exp) 
    return count } } function getCookieVal(offset) { var endstr = document.cookie.indexOf 
    (";", offset); if (endstr == -1) endstr = document.cookie.length; return 
    unescape(document.cookie.substring(offset, endstr)); } function checkCount() { 
    var count = GetCookie('count'); if (count == null) { count=1; SetCookie('count', 
    count, exp); window.open(page, "", windowprops); } else { count++; SetCookie('count', 
    count, exp); } } // End --> </script>
    
    Code (markup):
    Then call it like this >
    
    <body OnUnLoad="checkCount()" >
    
    Code (markup):
    Hope that helps ;)
     
    gameOn, Aug 26, 2008 IP
  3. acepsdr

    acepsdr Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Example I have javascript like this and I put in <header>...</header>:

    <SCRIPT LANGUAGE="JavaScript" SRC="http://www.mysite.com/exitexchange/popup.php"></SCRIPT>

    How to translate this to your code?
     
    acepsdr, Aug 26, 2008 IP
  4. acepsdr

    acepsdr Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sory, not above code. I mind like this:

    echo "function popup() {\n";
    echo " window.open('$url','popup','scrollbars=yes,location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no');\n";
    echo " self.focus();\n";
     
    acepsdr, Aug 26, 2008 IP
  5. gameOn

    gameOn Member

    Messages:
    624
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    35
    #5
    Thts simple jus add this at at the start of body (for your code, given above)

    
    echo "<body OnUnLoad="popup()" >" ;
    Code (markup):
     
    gameOn, Aug 27, 2008 IP