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!

Back Button

Status
Not open for further replies.

Andy6666uk

Programmer
Jul 11, 2001
17
GB
How can I make the browsers back button take someone two pages back?

thanks, Andy
 
I think this will do it for you
Code:
parent.history.go(-2)
 
You can't reassign actions to executable programs like a browser with client side Javascript. What if someone decided to make the back button close the window, or print the page, or some other unusual function? Would you like someone to be able to mess with YOUR browser functions like that? This isn't being sarcastic, just showing what you're really asking to be able to do, in an effort to show why it's not allowed.
 
sorry, yes I misunderstood the question, as trollacious pointed out, you can't go messing around with people's browsers, the code I gave you is a little bit of javascript. You could use it as follows:
Code:
<A href=&quot;#&quot; onClick=&quot;parent.history.go(-2); return false;&quot;>Back</A>
When the user clicks on the link, it'll go back twice in the history instead of once. However, there's nothing stopping the user from clicking on the back button instead, I know personally I'd use the back button. At least with that, I know exactly where I'm going to be at. As trollacious also pointed out, it's best not go take control from the user by making things behave differently than they normally would, visitors are less likely to come back. I think you'll find that's the general opinion from anybody you ask, and I'm just an amateur!


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top