<html>
<script language="JavaScript">
<!--
function test(){
alert("test");
}
function attach_Event(){
document.body.onclick = new Function("test()"); //或用mousedown
alert("attached event");
}
//-->
</script>
<body style="height:100% ">
<input type="text" id="text1"><input type="button" onclick="attach_Event()" value="attachEvent"></body>
</html>
应该是body区域的原因,你把它设为100%
<script language="JavaScript">
<!--
function test(){
alert("test");
}
function attach_Event(){
document.body.onclick = new Function("test()"); //或用mousedown
alert("attached event");
}
//-->
</script>
<body style="height:100% ">
<input type="text" id="text1"><input type="button" onclick="attach_Event()" value="attachEvent"></body>
</html>
应该是body区域的原因,你把它设为100%
改写成document.onclick = new Function("test()"); 也可以了,不知道firefox下body的具体实现