By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,668 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

document.links["id"].href -> Browsersafe?

P: n/a
Does this work in most browsers, namely MSIE?

document.links["idOfTheElement"].href

or does it have to be

document.links[0].href

?

Thanks and cheers,
Konrad
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Konrad Mathieu wrote:
Does this work in most browsers, namely MSIE?

document.links["idOfTheElement"].href

or does it have to be

document.links[0].href

?

Thanks and cheers,
Konrad


Why not try it?

<body onload="alert(document.links['test'].href);">
<a href="test.html" id="test">A Link</a>

The above works in Mozilla 1.5a, not IE

<body onload="alert(document.links('test').href);">
<a href="test.html" id="test">A Link</a>

The above works in IE, not Mozilla 1.5a

<body onload="alert(document.getElementById('test').href );">
<a href="test.html" id="test">A Link</a>

The above works in IE 6SP1, Mozilla 1.5a and Opera 7.11. I didn't check
the first two test in Opera because each failed in at least one of the
two major browsers you probably want to support. Also, simply because I
provided specific browser versions does not mean it won't work in early
versions, it simply means those are the versions I tested the code with.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

P: n/a
"Konrad Mathieu" <no****@nospam.com> wrote in message news:<10****************@doris.uk.clara.net>...
thanks!

"Grant Wagner" <gw*****@agricoreunited.com> schrieb im Newsbeitrag
news:3F***************@agricoreunited.com...
Konrad Mathieu wrote:
Does this work in most browsers, namely MSIE?

document.links["idOfTheElement"].href

or does it have to be

document.links[0].href

?

Thanks and cheers,
Konrad

The links collection seems to support the item method in both IE 6 and Netscape 7:

<a href="a.htm" id='a1' name='anchor1'
onclick="alert(document.links.item('a1').name); return false;"
Anchor Name</a>


Not an expert. FWIW.


Why not try it?

<body onload="alert(document.links['test'].href);">
<a href="test.html" id="test">A Link</a>

The above works in Mozilla 1.5a, not IE

<body onload="alert(document.links('test').href);">
<a href="test.html" id="test">A Link</a>

The above works in IE, not Mozilla 1.5a

<body onload="alert(document.getElementById('test').href );">
<a href="test.html" id="test">A Link</a>

The above works in IE 6SP1, Mozilla 1.5a and Opera 7.11. I didn't check
the first two test in Opera because each failed in at least one of the
two major browsers you probably want to support. Also, simply because I
provided specific browser versions does not mean it won't work in early
versions, it simply means those are the versions I tested the code with.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*

http://devedge.netscape.com/library/...3/reference/fr
ames.html

* Internet Explorer DOM Reference available at:
*

http://msdn.microsoft.com/workshop/a...l_reference_en
try.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html

Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.