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

Can't use <Back> button from a redirected page

Status
Not open for further replies.

engcomp

Programmer
Jun 18, 1999
66
AU
If I redirect from the index.html of my site to another page, say main.html, the <Back> button takes me back to index.html, which redirects me back to main.html.

To get out from this infinite loop, I have to use the <Back> button's history.

Anyone know of a better way?

It's a problem I have noticed on a number of sites.

Thank you and warmest regards, Helmut
 
>>It's a problem I have noticed on a number of sites. its a problem of frames Victor
 
Yes, could be a problem with Frames on other sites.
But on my site,
it is the redirection that causes the problem.

I could put a [Go back] form-button on the page and program it with History(-2), but this would not help the user who clicks the browser's <Back> button.

Why do I want to redirect? Please let me know if you are really curious.

Thank you and best wishes, Helmut
 
Put something like this on you &quot;referring page&quot;
Code:
<script language=&quot;JavaScript&quot;><!--
if (document.referrer.indexOf('
YourDomain.com
Code:
') <= -1) 

{location.href = '
PageToForwardTo.htm
Code:
';}
else {history.go(-2);}
//--></script>

This will forward the user to the page and if they go back it will send them to the page before the forwarding page. You might want to add some sort of test to make sure their was a page before the forwarding page though - otherwise they'll get a &quot;page cannot be displayed&quot;. This can be easily written to handle the &quot;double back&quot; problem.

I dont have time right now, but this would make a great FAQ if someone else would like to take the initiative?? -gerrygerry
Go To
 
Thank you, gerrygerry

Unfortunately, the redirection on my site is not made by me but by formmail.cgi, which I use to send an email to me when a user hits my site. The only lines in index.html are as follows:

<html>
<head>
<script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;>
<!--
function GetCookie(name) {
//... the usual stuff
}

function InitializeForm() {
document.notify.realname.value = visitorname;
document.notify.email.value = visitoremail;
document.notify.submit();
}

var visitorname = GetCookie('visitorname');
var visitoremail = GetCookie('visitoremail');

// -->
</script>
</head>
<body onload=&quot;InitializeForm();&quot;>

<form name=&quot;notify&quot; action=&quot; method=&quot;POST&quot;>
<input type=hidden name=&quot;recipient&quot; value=&quot;engcomp@ozemail.com.au&quot;>
<input type=hidden name=&quot;subject&quot; value=&quot;notify main&quot;>
<input type=hidden name=&quot;redirect&quot; value=&quot; <input type=hidden name=&quot;email&quot; value=&quot;noEmail&quot;>
<input type=hidden name=&quot;realname&quot; value=&quot;noName&quot;>
<input type=hidden name=&quot;env_report&quot; value=&quot;REMOTE_HOST,REMOTE_ADDR,REMOTE_USER,HTTP_USER_AGENT,HTTP_REFERER&quot;>
</form>

</body>
</html>

Now, it I could find a form2email.cgi script that doesn't insist on sending a &quot;thank-you&quot; page, I could put this hidden form in the main.html and make the main.html the site's index.html, because the email would be sent without any attempt to generate a page.

Any ideas? Thanks again, Helmut
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top