SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    history.go(-1) in Opera

    I'm using
    Code HTML4Strict:
    <a onclick="history.go(-1);return false;" href="test.php">&laquo; Back</a>

    In FF works ok but in Opera it needs 2 clicks to work properly. Does anyone knows a fix for this?

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It might have something to do with Opera's way of going back super fast.

    Ultimately you could do something like this:
    HTML Code:
    <a href="lastpage.php" id="back">Back</a>
    Code Javascript:
    document.getElementById('back').onclick = function(e) {
      if (!e) window.event.returnValue = false;
      else e.preventDefault();
      history.go(-1);
      window.setTimeout(function() {
        history.go(-1);
      }, 200);
    }
    A bit hacky but it might be the only thing to do.

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That code should work. Is there a frame on the page?

  4. #4
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Raffles, it works now.

    @QMonnkey
    There are no frames.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •