编写HTML代码时候用iframe中弹出层覆盖整个页面,代码如下:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “
http://www.w3.org/TR/html4/loose.dtd”>
<HTML><head><script>var cover =mydiv= null;window.onload = function() { cover=document.getElementById(‘coverdiv’); cover.style.width = Math.max(document.documentElement.scrollWidth, document.documentElement.clientWidth)+ “px”; cover.style.height = Math.max(document.documentElement.scrollHeight, document.documentElement.clientHeight) + “px” cover.style.display = “none”; mydiv = document.getElementById(‘mydiv’); with (mydiv){ style.width = document.documentElement.scrollHeight/2+”px”; style.height = document.documentElement.scrollHeight/2+”px”; style.left = (document.documentElement.scrollWidth – mydiv.offsetWidth)/2+”px”; style.top = (document.documentElement.scrollHeight – mydiv.offsetHeight)/2+”px”; style.display = “none”; }};function popit(){ mydiv.style.display=cover.style.display = ”;}</script></head><BODY><div id=’coverdiv’> </div><div id=’mydiv’>偶的层 <br><input value=”关闭” type=”Button” onclick=”javacript:mydiv.style.display =cover.style.display = ‘none’;” /></div><iframe id=aaa src=”222.htm”></iframe></BODY> </HTML>Button按钮点击调用上面的事件:
<button onclick=”javascript:parent.popit();”>弹出</button><br><br>