PDA

View Full Version : open a new window when user leaves my site



millie
07-29-2009, 11:58 AM
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

leescatnet
07-29-2009, 04:03 PM
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

wysiwyg4
07-31-2009, 12:10 AM
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

Watdaflip
07-31-2009, 05:36 AM
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



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

wysiwyg4
07-31-2009, 11:14 AM
The script above will only be executed when the visitor
clicks on that button.

millie
07-31-2009, 01:53 PM
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.

Karen Mac
07-31-2009, 02:46 PM
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

wysiwyg4
07-31-2009, 03:08 PM
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.

millie
07-31-2009, 03:36 PM
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