Special Character @ doesn't display in IE 6 & 7 when assigned to anchor text through ja

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
<script language="javascript">
function fnload()
{
var ctrl = document.getElementById("anchor");
ctrl.innerHTML = ("Arun@Prasad");
ctrl.href = "http://www.microsoft.com";
}
</script>
</head>
<body onload="fnload()">
<a id="anchor"></a>
</body>
</html>

The above code should display Arun@Prasad, but displays its Href value www.microsoft.com instead.
Am i wrong anywhere with my code.This works fine with other browsers(Opera,Firefox...etc).

But when i first assign href value & then assign innerHTML value, it works fine.....Pls anyone help me out fix this.......

[874 byte] By [japc] at [2008-1-10]
# 1

I see the behavior you describe and, to be honest, I'm not entirely surprised. According to the reference page on MSDN, "When an anchor is specified, the link to that address is represented by the text between the opening and closing anchor tags." In other words, the content between the opening tag and the closing tag is documented as being overwritten when the href changes.

I did spend several minutes reviewing the W3 specs to see if there wqas any specific guidance on this and didn't find it. that doesn't mean it doesn't exist, just that I didn't find it during my search. Your mileage may vary, of course.

Given the behavior, it seems wiser to modify the label after changing the location.

Also, you may wish to recosider this approach. I'm not sure what you're trying to accomplish, but remember that folks can have scripting disabled. Thus, your anchor may end up blank.

If you're looking to dynamically change the anchor based on context, perhaps a server-oriented solution would be more effective.

Hope this helps...

-- Lance

LanceLeonard at 2007-10-3 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...
# 2

Thanks Lance.....for your guidance

japc at 2007-10-3 > top of Msdn Tech,Internet Explorer Development,Internet Explorer Web Development...