Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Nov 2005
    Posts
    55
    Member #
    11943
    I'm stuck with a site that works in Safari, and Firefox but not IE.

    Here's the situation:

    A common page linked to from a multitude of sources. On the page is a "back" button that should take the user back to the original page. <a href="javascript:history.go(-1)">

    This works fine except the page with the back button also includes several hidden layers that are viewable with an "onclick" function in the anchor tag. So the user can click on several buttons and the content will change on the page itself.

    So far so good. Except once the user uses the onclick function the "back" button doesn't work consistently from browser to browser.

    I was able to work around this in Firefox and Safari, by adding another hidden layer that swaps the back button from a "-1" javascript to a "-2" <a href="javascript:history.go(-2)">. Works no matter how may clicks the user does on the page. The back button takes them back to their original location.

    A hack, but fixed the problem, until I tested it in IE on a PC.
    IE ignores the interior "onclicks" and jumps the user back 2 pages. To the page previous of the original. Short of opening a new window, (which the client doesn't want) I'm stumped.

    The only thing I can think of is to add a browser detector, so when IE is being used it displays:
    <a href="javascript:history.go(-1)">
    for any other browser it displays:
    <a href="javascript:history.go(-2)">

    But I don't know how to write this and the solutions I've seen online seem to work with page redirects or alerts. Not replacement of specific content. Or they focus on Netscape Navigator (detecting for version 4).

    Does anyone have any ideas? Any better way to return the user to the original page, or a simple javascript that will do the detection and replacement I'm describing?

    Any help would be appreciated.
    Thank you.

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Your problem is that the anchors change the URI of the page, which other browsers tend to consider a `historyable' action, if you will. Apparently IE doesn't... Knew there were a ton of reasons I didn't like that browser :-P

    Anyway, the way to resolve it is to drop that URI from the anchor tags. Instead of making their href point to #, leave the href off entirely and make sure that any onclick function returns false. This will prevent the default behavior, which for an anchor tag is updating the URI (which, without a href, they will do by refreshing the current page). Then you should be able to use -1 for all browsers.

  4. #3
    Member
    Join Date
    Nov 2005
    Posts
    55
    Member #
    11943
    Removing the 'href="#"' worked. Thank you.

    This also removed the finger pointer indicating the button as a link. So I played around a bit. Your statement about the "return false" was a great clue.

    Adding a ";return false" after the onclick function (without removing the href) also worked, and the link retained the finger.

    Tested it on a bunch of browsers and all works and all looks good. Again, thanks so much for your help.

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Ah, yes. The other alternative is using CSS to set the cursor to `pointer' over the anchor tags, but leaving the href in there works, too.

    Glad to be of help!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 06:02 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com