A
André Wagner
I'm trying to get all the "divs" that have a given NAME using
getElementsByName(). For example, the following code:
<html>
<head>
<script type="text/javascript">
function on_load()
{
var pages = document.getElementsByName("name");
alert(pages.length);
}
</script>
<body onload="on_load()">
<p name="name" id="id">Teste</p>
</body>
<html>
when I open this page in Firefox, it gives me a popup saying "1", that
is correct. But if I do it in Opera, it gives me "0".
Testing, I found out that changing the line to
var pages = document.getElementsByName("id");
in Opera gives me the correct result. So the Opera function
getElementsByName() returns me the objects, not according the NAME, but
according the ID. (which is wrong, according to
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259).
Am I speaking nonsense here, or is Opera doing the wrong thing? In this
case, how can I have all objects according to the NAME? (no, I can't
just use the ID)
Thank you in advance.
André
getElementsByName(). For example, the following code:
<html>
<head>
<script type="text/javascript">
function on_load()
{
var pages = document.getElementsByName("name");
alert(pages.length);
}
</script>
<body onload="on_load()">
<p name="name" id="id">Teste</p>
</body>
<html>
when I open this page in Firefox, it gives me a popup saying "1", that
is correct. But if I do it in Opera, it gives me "0".
Testing, I found out that changing the line to
var pages = document.getElementsByName("id");
in Opera gives me the correct result. So the Opera function
getElementsByName() returns me the objects, not according the NAME, but
according the ID. (which is wrong, according to
http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-71555259).
Am I speaking nonsense here, or is Opera doing the wrong thing? In this
case, how can I have all objects according to the NAME? (no, I can't
just use the ID)
Thank you in advance.
André