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

H

Heiko Pliefke

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
 
L

Lasse Reichstein Nielsen

Heiko Pliefke said:
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" :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top