当前位置:Gxlcms > JavaScript > js如何设置在iframe框架中指定div不显示

js如何设置在iframe框架中指定div不显示

时间:2021-07-01 10:21:17 帮助过:15人阅读

代码如下:

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>测试</title>
<script language="javascript" type="text/javascript">

function getStyle() {

if (window.top == window.self) {

document.getElementById("top").style.display = 'block';

} else {

document.getElementById("top").style.display = 'none';


}

}
</script>

</head>
<body onload="getStyle();">
<form id="form1" runat="server">
<div id="top">
在框架中不显示,正常访问显示
</div>
</form>
</body>
</html>

当当前页面正常访问时显示div top

当当前页面在iframe中时页面不显示 div top

人气教程排行