+ Reply to Thread
Results 1 to 9 of 9

Thread: open a new window when user leaves my site
      
   

  1. #1
    millie is offline First Lieutenant
    Join Date
    Apr 2009
    Posts
    170

    Default open a new window when user leaves my site

    Hello

    Not sure if this is the correct forum for this question. What I want to do is; open a new window (to say good-bye and please come again) when a visitor leaves my website (going to another site or closing the browser). I tried the onUnload event, javascript function, window.open ('http://subeagle.com'); properties of a page, but that did not work. Can someone point me to where I can read and learn how to do this properly?

    Thanks

  2. #2
    leescatnet is offline Master Sergeant
    Join Date
    Jul 2009
    Posts
    63

    Default Re: open a new window when user leaves my site

    easy set the link to open in a new tab and they won't leave your site jsut set it to _blank or for more info see the tutorials here

    http://www.vodahost.com/tut_bluevoda.htm
    Sincerly Leescatnet

  3. #3
    wysiwyg4 is offline Major
    Join Date
    Nov 2007
    Posts
    481

    Arrow Re: open a new window when user leaves my site

    Hi Millie,

    I don't know if you have come up with the answer yet or not,

    The following code will go between the HEAD tags.

    <SCRIPT LANGUAGE="JavaScript">

    function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=1,scrollbars=1,location=1,statusbar=1,men ubar=1,resizable=1,width=400,height=500,left = 312,top = 134');");
    }
    </script>

    And the following will go on your page in HTML box

    <form>
    <input type=button value="You come back now, you hear" onClick="javascript:popUp('http://www.yoururl.com/message.html')">
    </form>

    P.S. If you look at the function, you have

    toolbar=1,scrollbars=1,location=1,statusbar=1,menu bar=1,resizable=1 and
    of course the size of the window.

    Anything you don't want, you put a 0 in place of 1.

    Try it and see if that's what you want. You have to make a thank you page with a message or whatever. I call it message.html

  4. #4
    Watdaflip's Avatar
    Watdaflip is offline Major General
    Join Date
    Sep 2005
    Location
    Cincinnati, Ohio
    Posts
    2,119

    Default Re: open a new window when user leaves my site

    I don't know if you want a to load a different webpage, or just a small prompt they can hit just "Ok" and it closes.

    If its the latter, you can just insert this code inside your <body> tag

    Code:
    
    onbeforeunload="alert('Goodbye, please come again!');"
    If you want an actual popup window replace the whole alert() funciton in he code above with somelike like the window.open() function in the post above mine.

    Do note, this is going to annoy the hell out of frequent visitors to your site. When people close out of your site they probably won't want to be bothered with another window that opens up (or a simple prompt for that matter). Just something to think about.

    Hope that helps

    Register/Login Script
    Do you use a Password Protected Directory? Need a way to allow users to make their own account, try my .htaccess Login Script

  5. #5
    wysiwyg4 is offline Major
    Join Date
    Nov 2007
    Posts
    481

    Default Re: open a new window when user leaves my site

    The script above will only be executed when the visitor
    clicks on that button.

  6. #6
    millie is offline First Lieutenant
    Join Date
    Apr 2009
    Posts
    170

    Default Re: open a new window when user leaves my site

    All

    thanks for the guide. Unfortunately, I am still working on how to do what I want to do. Let me explain so that it's clear (I hope - I need to really get out of this bad sentence construction. I am sure it has a name that english professors always warn their students about.)

    This is what I want to do. I want to popup a small window with 'sorry to see you go and please come back soon' message. I want this popup window to appear when:

    1) the visitor leaves my website (the URL changes from my website to another, is there an event for this that can be monitored?)
    2) the visitor closes the browser (is this an onUnload?)

    These are the events I want to capture so I can then popup my "pleading" window.

    Please let me know if this is still confusing. Thanks for the assist.

  7. #7
    Karen Mac's Avatar
    Karen Mac is offline General
    Join Date
    Apr 2006
    Location
    X marks the spot
    Posts
    8,354

    Default Re: open a new window when user leaves my site

    You can do this with popunder or popover scripts however, you will annoy 99&#37; of people and they will NEVER come back. It might grab a few but it will chase off even more. Also.. if they use any kind of site monitoring tools .. this will get you on the bad list and might even get you blocked from future viewing.

    If you want scripts that do this, just google popups or pop unders.

    Karen

    VodaHost

    Your Website People!
    1-302-283-3777 North America / International
    07031847328 / United Kingdom

    ------------------------

    Top 3 Best Sellers

    Web Hosting - Unlimited disk space & bandwidth.

    Reseller Hosting - Start your own web hosting business.

    Search Engine & Directory Submission - 300 directories + (Google,Yahoo,Bing)



  8. #8
    wysiwyg4 is offline Major
    Join Date
    Nov 2007
    Posts
    481

    Arrow Re: open a new window when user leaves my site

    I agree with Karen 100%.

    I always try to make it simple not for myself
    but entirely for the visitor.

    Sooner or later - in most cases it would be sooner - visitors are gonna
    leave your website because it is their choice not the webmasters.

    What the website builder can do, ideally, is to have the best and fresh
    content on the subject of your website, make it easier for them
    to navigate not with some fancy and flashy things but solid, to the point,
    and concise presentation of the material.

    If the visitor stays on your site for a couple of minutes or more,
    you have done your job.

    Try to give the visitor good contents and in turn you would get a
    little closer to the search engines as well.

    Bells and whistles are fine if they make some good business sense.
    Otherwise the visitor gets annoyed. Think of the visitors as annoyed to
    begin with. Your job as webmaster is to remove their annoyance and
    attract their attention.

    Having said that, you can still do what Karen said.

  9. #9
    millie is offline First Lieutenant
    Join Date
    Apr 2009
    Posts
    170

    Default Re: open a new window when user leaves my site

    All

    thank you for the assist. I have done what I wanted to do due mainly to your help. Much appreciated. After re-publishing with the flash feature, and trying it out myself, I then decided to follow your business web-sense and removed the annoying feature. 2 lessons for today, that is more than i usually get in a week.

    Thank you wysiwg4, watdaflip, and karen

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49