SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Apr 2001
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a script that will allow you to have a pop-up window open when you leave a domain (or exit your browser), but will still allow you to navigate within your domain without the pop-up window opening on every page?

    Thank you.

  2. #2
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know about the onUnload event? Is this what you're talking about? I mean, I'm kind of confused with your post.

    Have you tried to use the onUnload event? If not, I may be able to provide some code for it.

    Post back here for more info.
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  3. #3
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    onUnload wouldn't work completely as it would open the popup while still in your site.

    There is a way to do it so that the popup only pops up the first time you leave a page - but it'll still do it if you're going to another page.

    The problem is javascript can't see into the future - when you're leaving a page you don't know where you're going to - the only way to actually know if you're leaving a site or not when the page closes before the page closes would be to run a script on all the links.

    Regardless it'd be very complicated - perhaps an option that only pops up once would be better.

    Sitepoint has a script that they use to show their tribune pop up - it uses cookies and will only show once for each visitor.

    http://www.webmasterbase.com/static/popjs.php?
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  4. #4
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you can do it with ASP
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  5. #5
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,939
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ASP cannot read the future any more than JS can. Besides you need a client side scripting language.
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  6. #6
    Say WHA?! goober's Avatar
    Join Date
    Sep 2000
    Location
    United States
    Posts
    1,921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by aspen
    ASP cannot read the future any more than JS can. Besides you need a client side scripting language.
    Aspen, come on... joke?

    lol.. I believe I may have been stupid. I apologize. I posted this one early in the morning. My post has all the properties of a bad post. One liner, not saying anything, argumentative, AND trying to be funny. Sorry. I screwed up there.

    Forgive me?
    Sean Killeen [LinkedIn] [Twitter] [Web]

    Warning: Reality.sys corrupted. Universe halted. Reboot? (Y/N)

  7. #7
    I'm a college yuppie now! sbdi's Avatar
    Join Date
    Jul 2000
    Location
    Dublin , Ireland
    Posts
    1,271
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I cant seem to get this script to work can anyone tell me whats wrong?

    Code:
    <html>
    <head>
    <title>Untitled Document</title><SCRIPT LANGUAGE="JavaScript">
    
    function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    
    function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i &lt; 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 = (2 &lt; argc) ? argv[2] : null;
    var path = (3 &lt; argc) ? argv[3] : null;
    var domain = (4 &lt; argc) ? argv[4] : null;
    var secure = (5 &lt; argc) ? 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 DisplayInfo() {
    var expdate = new Date();
    var visit;
    expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
    if(!(visit = GetCookie("visit"))) 
    visit = 0;
    visit++;
    SetCookie("visit", visit, expdate, "/", "damnyanks.com", false);
    var message;
    if(visit == 1) 
    popup()
    }
    
    
    /////////////editable part///////////////////////////////////////
    function popup(){
    window.open('http://www.damnyanks.com/popup.cfm','win1','width=550,height=440,resizable')
    }
    
    /////////////editable part///////////////////////////////////////
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="refresh" content="0;URL=http://www.damnyanks.com/forums">
    </head>
    
    <body bgcolor="#FFFFFF" OnUnload="DisplayInfo()">
    
    </body>
    </html>
    Back Again


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •