www.webdeveloper.com
Results 1 to 11 of 11

Thread: reading location.hash IE 6

  1. #1
    Join Date
    Jan 2003
    Posts
    11

    reading location.hash IE 6

    IE 6 doesn't seem to be updating location.hash or location.href after using the back button.
    This works in netscape and moz. but not IE.
    http://www.mustardlab.com/developer/test/anchors.html

    On the page I'm trying 3 different methods to set the hash
    setting: location.hash = 'hash'
    setting: location.href = 'anchors.html#hash'
    setting: hash through regular link

    JS will read the hash once it's been set, but hitting back doesn't seem to be updating the location object.
    Any thoughts on how to get it to read the hash after hitting back?

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    The "Back" button contains an array of the window.location.href not of the document
    You need to give the full URL to window.location.href for the "back" button to work
    Was this your intention?

  3. #3
    Join Date
    Jan 2003
    Posts
    11
    I tried reading window.location.href and window.location.hash and that didn't work either.

  4. #4
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    For security reasons you can not read this array.

  5. #5
    Join Date
    Jan 2003
    Posts
    11
    I'm not trying to read the history array, I'm trying to read the current document.location. When you hit the back button the url location doesn't update.

  6. #6
    Join Date
    Dec 2002
    Location
    High on life
    Posts
    10,104
    Can you post a link to an example of what you are talking about? Also, this might help.

    Personal website http://www.ryanbrill.com/
    Business website: http://www.infinitywebdesign.com/
    TypeSpace http://www.typespace.org/

    I reject your reality and substitute it with my own!

  7. #7
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Are you not trying to go to a bookmark that does not exist?
    Your code does cause an error in Mozilla.

  8. #8
    Join Date
    Jan 2003
    Posts
    11
    pyro, there is a link in my first post refering to the problem. I have an interval running which displays the location.href and location.hash of the current page, when you click one of the buttons or links, the text fields update with the new href and hash information, but when hitting the back button, the hash and href don't update, interestingly enough, the link you gave me does update when hitting the back button.

  9. #9
    Join Date
    Jan 2003
    Posts
    11
    looking at the link you posted further, it appears they are actually sending the browser to a new page, rather than sending the browser to an anchor within that page.

    I need a method for finding out which anchor they are at after hitting the back button, without sending the current document to a new page everytime.


    Fang, I'm not sure what you mean. I'm not trying to go to a bookmark, I just need to know what anchor the user is currently located at.

  10. #10
    Join Date
    Jan 2003
    Posts
    11
    the code for teh page is just a timeout interval output location.href and location.hash

    PHP Code:
    function startwatch(){
        
    setTimeout(startwatch100);
        
    document.getElementById("intervalcheck").value i++;
        
    document.getElementById("hashoutput").value document.location.hash;
        
    document.getElementById("hrefoutput").value document.location.href;


  11. #11
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    document.location.hash will give you the anchor.
    The problem with IE appears to be the reference to "top".
    Change "top" to "tops" and the problem disappears.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles