Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 1st, 2004, 10:31 AM
Registered User
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Back button using Javascript in IE 5.5+

Hi there ... I'm really hoping someone out there has a solution for me. This seems like such a simple thing. I just need to code a Back button on a jsp to go back to the referring page. This is the flow of pages:
sendMessage.jsp posts to thankYou.jsp. thankYou.jsp includes sessionCheck.jsp. If sessionCheck.jsp determines that the session is not valid, it sets the current.location to messageNotSent.jsp. On messageNotSent.jsp, I want a 'Back' button so that users can go back to the page where they were entering their message, which is sendMessage.jsp.

I've tried
- both of which just reload the messageNotSent.jsp page

window.location.href = document.referrer
- returns an undefined page, but if I use Forward on right mouse menu, I get the page I want.

Of course this is easy as pie in Netscape/Mozilla ... damm microsoft! :)

Please please ... any suggestions are appreciated in advance!


Old November 1st, 2004, 12:43 PM
joefawcett's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts

If hitting the forward button gives you the correct action why not script
, what code do you use in Netscape?


Old November 1st, 2004, 12:52 PM
Registered User
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

For IE right now I'm using
window.location.href=history.back(-2). This takes me to a "page could not be loaded" and the url in my tomcat output says:
2004-11-01 11:42:08 - Ctx( ): 404 R( + /aw/jsp/awSendMessage/undefined + null) null

From this page if I use Forward on the right mouse button I get to the page I want. I tried window.location.href=history.back(-1), but this doesn't work either.

In Netscape I'm using history.go(-1) and it works fine.

Old November 1st, 2004, 01:06 PM
Registered User
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts

Sorry ... my mistake ... from the "page undefined" page, if I click "BACK" from the right mouse menu I get the page I want.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Back Button j_rumpa Javascript How-To 8 July 4th, 2007 08:29 AM
Javascript, SSL, and Back Button jdhemphill Javascript How-To 0 January 31st, 2007 09:44 AM
Back Button in IE kishor_ys BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 September 4th, 2006 09:05 AM
Back Button abdul_owiusa General .NET 1 November 11th, 2005 09:58 AM
history.back or hitting the back button won't work lian_a Classic ASP Basics 4 July 29th, 2004 12:14 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.