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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

link back button browser to behavior?

Status
Not open for further replies.

eisbaer

Technical User
Aug 12, 2003
1
DE
Hi,

on a new site i will open a Popup when the surfer leaves my Site.

therefore i have this little script:


var console=true;
function exit(){
var url2='if (console)
open(url2, 'exit_console');
}



it activates on the pciture/banner on the top of the site with
onunload="exit()"

if the surfer clicks on a permitted link that moves him into the site i have linked these links with:

onClick="console=false"

this works perfectly fine...

BUT, when the surfer clicks the Back Button in the browser to go back on page the popup opens up also.

Do you have any solution for that? Or if there is absolutely none a better possibility for it. (how it would work fine with frames I know, but I won't use them)

you can see this on(attention nudity (no hardcore))


Thanks a lot

eisbaer
 
Detect back button script example (depends on fact that page is only loaded from cache if back buton is pressed):

<HTML>
<BODY ONLOAD=&quot;handleBackButton(); &quot;>
<FORM NAME=&quot;_mine&quot;>
<INPUT NAME=&quot;_a1&quot; VALUE=&quot;1&quot; STYLE=&quot;visibility:hidden&quot;>
</FORM>
<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
var x=&quot;1&quot;;
var isBack;
function handleBackButton(){
isBack = (x != document._mine._a1.value);
document._mine._a1.value=2;
document._mine._a1.defaultValue=2;
}

function isBackButtonUsed(){
return isBack;
if (x >= 1)
{alert(&quot;he he&quot;);}
}
</SCRIPT>
<H1>Back button testing</H1>
<form>
<input type=button value=&quot;is back button&quot; onclick=&quot;(isBackButtonUsed())?
alert('Back button was used'):alert('Page was loaded normally')&quot;>
<input type=&quot;text&quot; size=&quot;19&quot;>
</form>
</BODY>
</HTML>
 
Here's one scenario:

-Keep your script the way it is, letting the page open the popup when unloaded, but positioned off the screen where the visitor can't see it.
-Whenever one of your pages loads, detect if the popup is open and close it
-In the popup, have a script that positions the popup to a viewable place on the screen after 5 seconds.

Adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top