SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    SitePoint Zealot ardit's Avatar
    Join Date
    Aug 2001
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exit popup script

    Hey there I want to have an exit popup thanking the visitors for their visit and giving them the option to leave a feedback. I got a script of a javascipt site here is the code

    [CODE]
    <script>

    /*
    Fair well window launcher script
    By JavaScript Kit (http://javascriptkit.com)
    Over 200+ free scripts here!
    */

    function openpopup(){
    //configure "seeyou.htm and the window dimensions as desired
    window.open("seeyou.htm","","width=300,height=338")
    }

    function get_cookie(Name) {
    var search = Name + "="
    var returnvalue = "";
    if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    if (offset != -1) { // if cookie exists
    offset += search.length
    // set index of beginning of value
    end = document.cookie.indexOf(";", offset);
    // set index of end of cookie value
    if (end == -1)
    end = document.cookie.length;
    returnvalue=unescape(document.cookie.substring(offset, end))
    }
    }
    return returnvalue;
    }

    function loadpopup(){
    if (get_cookie('popped')==''){
    openpopup()
    document.cookie="popped=yes"
    }
    }

    </script>

    <body onunload="loadpopup()">
    [CODE]

    The cookies work and the popup is desplayed once immidiatly after you leave the default page to go anywhere else in the site. Is there anyway to make it so that it pops up once the visitor leaves the entire website, the domain? The only thing that I have thought up to now is have an invisible frame somehow and have the code in there, but that would create problems with search engines and frames are never advisable.

    Anyone?

    Ardi

  2. #2
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There is no way through javascript to determine when they leave a site. I am not sure if you could do through server side scripts either.

  3. #3
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by requestcode
    There is no way through javascript to determine when they leave a site. I am not sure if you could do through server side scripts either.
    Not even close to true. You cannot do it server side, but you certainly can with JavaScript. I will say first off that is is very bad form to do so, however, if you don't mind losing repeat visitors, here goes:

    Code:
    <html>
    <head>
    <script language="javascript">
    <!--Cloak
    var exit=true; 
    function leave() { 
    if (exit) 
    window.open('thankyoupage.htm','','toolbar=no,menubar=no,
    scrollbars=no,resizable=no,location=no,height=400,width=400'); 
    } 
    // decloak -->
    </script>
    </head>
    <body onunload="leave()">
    </body>
    </html>
    There ya go
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  4. #4
    SitePoint Wizard silver trophy TheOriginalH's Avatar
    Join Date
    Aug 2000
    Location
    Thailand
    Posts
    4,810
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I should add that you'll need to make sure that internal links don't trigger it:

    Code:
    <a href="aninternallink.html" onclick="exit=false">An internal link</a>
    ~The Artist Latterly Known as Crazy Hamster~
    922ee590a26bd62eb9b33cf2877a00df
    Currently delving into Django, GIT & CentOS

  5. #5
    SitePoint Zealot ardit's Avatar
    Join Date
    Aug 2001
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    now that's complicated. The one that I have is hown only once per user through cookies, your script would come up everytime they leave the site right?

    And also I would have to add the second code that you wrote to every link on my site?

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    see here

    I posted a link in that thread that is now dead, but I C&P'd the code further down.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  7. #7
    SitePoint Addict
    Join Date
    May 2000
    Posts
    313
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    TheOriginalH wont your script still popup the window if they reload the page and also hit the browsers back or forward buttons to go to the previous/next page?
    Also he wanted to use the script from JavaScriptKit that sets a cookie so that the window does not popup again in the same browser session.

  8. #8
    SitePoint Zealot ardit's Avatar
    Join Date
    Aug 2001
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beetle I placed the code in the thread that you suggested but still it pops up after they leave the first page of the site. The cookies work but it is displayed immidiatly after they leave the first page of the site.

    My site is uses the osCommerce script and I placed the code in the header file which is called for every page of the site. There are a few different files that are requested through php for every page and I could place in those too but I don't see why it shouldn't be working.

  9. #9
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry - I never tested the script myself - as I don't care for such popups.

    Not sure what else to say - this is a technically difficult and morally touchy issue.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  10. #10
    SitePoint Zealot ardit's Avatar
    Join Date
    Aug 2001
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can si that it is "technically difficult" but I don't see how it is "morally touchy issue". It will be popup that will come up once for every visitor when they leave the site to gather feedback. For a just new open store I wouldn't know anyother way to get some feedback and improve the site on it based on users opinion.

  11. #11
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not saying it's wrong or right - or morally good or bad. There are those that think all popups are evil. There are those that find them acceptable in certain circumstances.

    You incapacity to see the issue doesn't negate it's existence.

    That's all I'm trying to say.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  12. #12
    SitePoint Zealot ardit's Avatar
    Join Date
    Aug 2001
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    beetle,

    I'm not incapable of seeing the issue and I know that it exists. Users including myself don't like popups, it's as simple as that. But I personally never mind one popup per session, and in the case of my site it will be a one popup for ever (of course if they never erase their cookies). It's a cute little popup thanking them for the visit and asking to leave their opinion on my new e-store (e.i. areas of improvement). In my specific case I don't see the moral implications. That it might be technically difficult that's a totally different thing.

  13. #13
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ardit
    I'm not incapable of seeing the issue...
    Quote Originally Posted by ardit
    ...I don't see the moral implications.
    Eh?

    Besides, why are you defending yourself? I'm not telling you you're wrong, nor that I won't help you because it's against my morals. I simply don't have anything additional (technical or otherwise) to add.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev





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
  •