Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Thanked 1 Time in 1 Post

    named anchors, back/foward and window.location in IE


    if i use an interval to poll window.location properties (href, hash or search), both IE and FF give accurate returns initially.

    using named anchors, the poll returns accurately in both.

    HOWEVER, if i navigate amongst the anchors and then use back/forward buttons - the address bar updates appropriately in both browsers, and the poll returns correctly in FF, but in IE it gives only the url of the last anchor manually clicked.

    function update(){
    	document.getElementById("statustext").value = window.location.href;
    window.onload = function(){
    <input id="statustext" />
    <a href="#1">1</a>
    <a href="#2">2</a>
    <a href="#3">3</a>
    <a name="1"></a>
    <a name="2"></a>
    <a name="3"></a>
    everything works fine EXCEPT in IE when back/forward buttons are clicked. the status won't change. in FF it works fine.

    is there a workaround?


  • #2
    Regular Coder
    Join Date
    Jan 2004
    Thanked 1 Time in 1 Post

  • #3
    Master Coder
    Join Date
    Feb 2003
    Umeå, Sweden
    Thanked 83 Times in 74 Posts
    Well, got some good news for you: HTML5 specs a new event, hashchange that is fired when the fragment identifier is changed but the page otherwise remains the same. This feature was introduced by Microsoft in an ie8b1. See HTML5 5.9.9 History Traversal, point 6:
    If the specified entry has a URL that differs from the current entry's only by its fragment identifier, and the two share the same Document object, then fire a simple event with the name hashchange at the body element, and, if the new URL has a fragment identifier, scroll to the fragment identifier.
    And: Internet Explorer 8 Beta 1 Whitepapers: Better AJAX Development

    I've read somewhere that one can use iframe elements in an elaborate fashion to make sure these are fragment identifier changes are inserted into the browsing history in earlier ie<8 though. I just don't know how, exactly, that is done, as that was not the topic of whatever blog post I saw it in. Google it, I know the answer must be out there somewhere.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • Users who have thanked liorean for this post:

    subhailc (09-04-2008)


    Posting Permissions

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