Strange behaviour in Internet Explorer with document.links[i].href

Discussion in 'Javascript' started by Heiko Pliefke, Feb 11, 2004.

  1. Hi NG!

    I have to change dynamically all hyperlinks, when the html-page is
    loaded at the client. This works fine, except in the following scenario:

    When the innerText of an anchor contains an '@', the InternetExplorer
    changes the innerText-Property to the HREF-Property. I have checked this
    with MoZilla/FireBird and Opera and there is no problem!

    To explain, what i mean, see following example:
    function atTest(){
    for(var i=0; i < document.links.length; ++i)
    {
    document.links.href = document.links.href;
    }

    }

    Now you need some anchor tags - notice the '@' as inner Text:

    <a href="http://www.somelink.org/">Text before @ and after</a><br>
    <a href="http://www.somelink.org/">Text before @</a><br>
    <a href="http://www.somelink.org/">@ before text</a><br>
    <a href="http://www.somelink.org/">Text before at and after</a>


    If you load the page, InternetExplorer will display the HREF-Property
    instead of "Text before @ and after" - all other elements are shown
    correctly! It doesn't bother other browsers: Opera/MoZilla shows _even_
    the first element with innerText.

    My system: Windows XP SP1, InternetExplorer SP1, Firebird0.7, Opera 7.23

    Has anybody out there an idea, why IE behaves like this? And how I can
    work around this?

    Any help/feedback is greatly appreciated! Best regards

    --
    Heiko Pliefke
     
    Heiko Pliefke, Feb 11, 2004
    #1
    1. Advertising

  2. Re: Strange behaviour in Internet Explorer withdocument.links.href

    Heiko Pliefke <kollateralschaden@_nospam_.net> writes:

    > When the innerText of an anchor contains an '@', the InternetExplorer
    > changes the innerText-Property to the HREF-Property. I have checked
    > this with MoZilla/FireBird and Opera and there is no problem!


    Indeed. Whenever IE believes that the content of an anchor element
    is itself an URL, assigning to the href of the anchor also changes
    the content. It happens if the content contains an "@", but also
    if it starts with, e.g., "http://"

    I guess it's what they call a "feature" :)


    --
    Lasse Reichstein Nielsen -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Feb 11, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Erik Ronne
    Replies:
    2
    Views:
    3,325
    Grant Wagner
    Feb 27, 2004
  2. Ed Hauptman
    Replies:
    7
    Views:
    1,025
    Ed Hauptman
    Aug 7, 2009
  3. Erik Ronne
    Replies:
    2
    Views:
    203
    Grant Wagner
    Feb 27, 2004
  4. Replies:
    2
    Views:
    482
  5. ft310
    Replies:
    8
    Views:
    123
    -Lost
    Jun 5, 2007
Loading...

Share This Page