Skip to content

Instantly share code, notes, and snippets.

@ryuone
Created April 7, 2011 11:20
Show Gist options
  • Save ryuone/907594 to your computer and use it in GitHub Desktop.
Save ryuone/907594 to your computer and use it in GitHub Desktop.
IE9RCのdocument.getElementsByNameの挙動がおかしい。
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<title>getElementsByName</title>
</head>
<body>
<!-- IE9RC : すべてlengthは1が返ってくる。 -->
<!-- Firefox : すべてlengthは0が返ってくる。 -->
<a id='aname' onclick="alert(document.getElementsByName('aname').length)">clickme(a)!!</a>
<div id='divname' onclick="alert(document.getElementsByName('divname').length)">clickme(div)!!</div>
<article id='articlename' onclick="alert(document.getElementsByName('articlename').length)">clickme(article)!!</article>
<canvas id='canvasname' onclick="alert(document.getElementsByName('canvasname').length)" style='border:1px solid #000;'>clickme(canvas)!!</canvas>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<title>getElementsByName</title>
</head>
<body>
<!-- IE9RC : a要素のみ1であとは0が返ってくる。 -->
<!-- Firefox : すべてlengthは1が返ってくる。 -->
<a name='aname' onclick="alert(document.getElementsByName('aname').length)">clickme(a)!!</a>
<div name='divname' onclick="alert(document.getElementsByName('divname').length)">clickme(div)!!</div>
<article name='articlename' onclick="alert(document.getElementsByName('articlename').length)">clickme(article)!!</article>
<canvas name='canvasname' onclick="alert(document.getElementsByName('canvasname').length)" style='border:1px solid #000;'>clickme(canvas)!!</canvas>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment