Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stumped: How to know where a visitor is heading next?

Status
Not open for further replies.

naveenpn

Programmer
Mar 5, 2001
2
MO
Can somebody please tell me how to detect reloads or atleast know which url the visitor is going to by capturing the onunload event?
 
I don't think you can have the user's destination if he write an new address in the location bar. But you can know where he will go when he clicks on a link in YOUR page. just insert the following code in each link :

<A HREF=&quot; onClick=&quot;HandleRef(this.href);&quot;>go to myserver.com</A>

Now between the HEAD tags :
<SCRIPT LANGUAGE=&quot;javascript&quot;>
function HandleRef(ref)
{
// Do what you want with the ref variable,
// which is the next location. By ex :
alert(&quot;You will go to : &quot; + ref);
}
</SCRIPT>
 
Let me tell what I need to do.
I want to popup a window for vistors leaving my website.
I set a flag in the beginning, and when the visitor leaves page, the unload event is called, I check the flag and if it is set, I popup a page. If the visitor clicks on links within my website, I use the onclick event to turn off the flag so that there is no popup by the onunload event.

But when the visitor reloads the page, there will be a popup. Is there any workaround for this?

How do I prevent the popups on reloading?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top