如何禁止iframe中的alert();

来源:百度知道 编辑:UC知道 时间:2024/05/14 14:22:10
就是别让页面中包含的框架页面弹出对话框来!
~急用谢谢!

写个例子给你,main.html是你的页面,alert.html是你页面里要嵌的页面

------alert.html------
<input type="button" value="alert" onclick="alert(1);"/>

------main.html-------
<body onload='init();'>
<script language="javascript">
function init()
{
document.getElementById("f").contentWindow.alert=function(){return null};
}
</script>
<iframe id="f" src="alert.html"/>
</body>