2010-06-18 3 views
0
<!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=utf-8" /> 
<title>Test</title> 
</head> 

<body> 
<div id="test"> 

</div> 
    <script type="text/javascript"> 
    var check = function(){ 
    alert(document.examsys); 
    } 
    var _form = document.createElement("form"); 
    _form.name = "examsys"; 
    _form.action="javascript:;" 

    for(var i=0 ; i<5; i++){ 
    _form.innerHTML += "<input type='radio' name='answer' value='ccc' />&nbsp;abc<br />"; 
    } 
    var submit = document.createElement("input"); 
    submit.type = "image"; 
    submit.src = "tijiao.gif"; 
    submit.alt = "Submit"; 

    if(submit.attachEvent){ 
    submit.attachEvent("onclick",check); 
    } 
    else if(submit.addEventListener){ 
    submit.addEventListener("click",check,false); 
    } 

    _form.appendChild(submit); 
    document.getElementById("test").appendChild(_form); 
</script> 
</body> 
</html> 

왜 IE6에서 document.examsys는 "정의되지 않음"을 반환합니까?javascript 질문에 대한 답변 IE6에서

+0

같은 뭔가를 시도? – deceze

+0

테스트 케이스에 불과합니다. 버튼을 클릭하면 "document.examsys"의 유형을 경고 할 수 있습니다. 결과는 object.but이어야합니다. ie6에서는 'undefiend'입니다. – CunruiLi

+0

_form.id = 'examsys'설정을 시도 했습니까? – Fopfong

답변

0

는 어떻게해야 무엇

document.forms[0]