您的位置:首页 > Web前端 > JavaScript

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

2013-12-04 09:53 323 查看
<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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  js javascript 框架 iframe
相关文章推荐