js中的事件,问题 HTML是顺序读取文件的.你把"DIV1"对象放在下面,当加载页面时是首先读取脚本的.oDiv.onclick=handleEvent;//这行报错.又没放在函数块里,自然读不到什么对象了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <div id="div1">aaaaaaaa</div><script> function handleEvent(oEvent){ if(oEvent.type=="click"){ alert("click"); }else if(oEvent.type=="mouseover"){ alert("Mouse Over"); }else{ alert("aaaa"); } } var oDiv=document.getElementById("div1"); oDiv.onclick=handleEvent;//这行报错. oDiv.onmouseover=handleEvent;</script> 從你的機器上能夠正常運行嗎?我這個還是抱錯在if(oEvent.type=="click"),現在報 'type'為null或不是一個物件. hehe -物件-<script> function handleEvent(oEvent){ if(oEvent.type=="click"){ alert("click"); }else if(oEvent.type=="mouseover"){ alert("Mouse Over"); }else{ alert("aaaa"); } } var oDiv=document.getElementById("div1"); oDiv.onclick=function(){handleEvent(event)}; oDiv.onmouseover=function(){handleEvent(event)};</script> jqery隐藏没有设置属性的层 怎么引用.js? 气死我了! 求教 ext fieldText 标签显示方式 js正则如何识别繁体啊 asp在<SCRIPT LANGUAGE="JavaScript">脚本的function函数里,怎样调用md5函数,,,,,,,,,,请知道者回答!多谢 一个简单的日期验证! 如何判断图片预截完成 请问一个关于触发图片显示或隐藏的问题,各位请帮下忙~~ 关于脚本文件 怎样在span里或者在img里再加上一个图片? 关于javascript 创建控件的问题 问一个javascript问题
</div><script>
function handleEvent(oEvent){
if(oEvent.type=="click"){
alert("click");
}else if(oEvent.type=="mouseover"){
alert("Mouse Over");
}else{
alert("aaaa");
}
}
var oDiv=document.getElementById("div1");
oDiv.onclick=handleEvent;//这行报错.
oDiv.onmouseover=handleEvent;
</script>
if(oEvent.type=="click"),現在報 'type'為null或不是一個物件.
<script>
function handleEvent(oEvent){
if(oEvent.type=="click"){
alert("click");
}else if(oEvent.type=="mouseover"){
alert("Mouse Over");
}else{
alert("aaaa");
}
}
var oDiv=document.getElementById("div1");
oDiv.onclick=function(){handleEvent(event)};
oDiv.onmouseover=function(){handleEvent(event)};
</script>