“Back” link not working in Firefox

Maybe some of you use the following approach to create “back” links:

<a href="#" onclick="javascript:history.back();">back</a>

I used to do it this way until it turns out that this is not working under Firefox.

Fortunately I found the solution while I was reading an article posted at Code Project website. The back button there was working even in Firefox. The code used is really simple:

<a href="javascript:history.back();">back</a>

Enjoy!

, ,
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Technorati
  • digg
  • Reddit
  • SphereIt
  • DotNetKicks
  • YahooMyWeb

2 Responses to “"Back" link not working in Firefox”


  1. 1 alberbetis Sep 11th, 2008 at 2:20 am

    This is that I was looking for, it works very well :-)

    Thank you very much!!

  2. 2 jjj Sep 29th, 2010 at 9:15 am

    I know this is old entry, but I was facing the same problem. Ended up here after some google and the solution here made me thinking what is the real cause due the “fix” suggested here.

    The real problem is that with code:

    back

    Firefox is executing the onclick, however Firefox is still executing the anchor link as well and moving the page to top. This cancels the history.back(). Now with proposed solution:

    back

    Firefox is just executing the anchor link, which in this case is entered as javascript block. All fine, and Firefox executes the history.back() as intended. However if you want to use the onclick and have that code work, you just have to tell Firefox not to execute the anchor (as originally intended):

    back

    Note the added “return false;”.


Google

Blogroll


Blogroll Me!

Enter your email address:

Delivered by FeedBurner







Academics Blogs - Blog Top Sites