javascript的getElementByName的问题

来源:百度知道 编辑:UC知道 时间:2024/07/08 16:39:07
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function load()
{
alert("1111");
var bb = document.getElementById("bb");
var inpu = document.createElement("input");
inpu.setAttribute("type", "text");
inpu.setAttribute("name", "Curtain1");
bb.appendChild(inpu);
var temp = document.getElementsByName("Curtai

你缺个id属性,在ie6中虽是根据name找对象但实际上是通过id找对象的,在ff和ie7中是直接通过name找的

(你的标题写错了,应该是getElementsByName)

我给你改了一下

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script language="javascript">
function load()
{
alert("1111");
var bb = document.getElementById("bb");
var inpu = document.createElement("input");
inpu.setAttribute("type", "text");
in