87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<script>
function $(id){
return( document.getElementById(id));
}
function a(event){
alert( 1 );
}
window.onload = function(){
var f = $("iframe1").contentWindow || $("iframe1").window;
f.document.onclick=a;
}
</script>
<body>
<iframe id="iframe1" src="2-2.html"></iframe>
</body>
</html>
<div><iframe id="ifInDiv" src="2.htm"></iframe></div>
<script>
window.onload=function(){
if(document.all)document.frames['ifInDiv'].document.onmousedown=function(){
MouseDown(document.frames['ifInDiv'].event);//注意获取的是iframe中的事件对象,直接event会是null
}
else document.getElementById("ifInDiv").contentWindow.document.onmousedown=function(e){
MouseDown(e);
}
}
function MouseDown(e)
{
alert(e);
}
</script>