我是靠谱客的博主 整齐悟空,这篇文章主要介绍解决iframe中fixed失效问题,现在分享给大家,希望可以做个参考。

代码如下:

aa.html

<html>
<head>
<meta name="" content="" charset="utf-8"/>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">

function say() {
    var box = "<div style='width:500px;height:500px;background:red;position:fixed;top:100px;left:100px;'></div>"
    $("body").append(box);
}
//调用bb页面中的创建button方法
function callChild(){
    myFrame.window.say();
}

</script>
</head>
<body>
    <input type=button value="aa页面调用bb" οnclick="callChild()">
    <iframe name="myFrame" src="bb.html"></iframe>
    <div style="height:3000px;"></div>
</body>
</html> 
bb.html

<html>
<head>
<script src="js/jquery.min.js"></script>
<script type="text/javascript">

function say(){
    $("body").append("<button>按钮</button>");
}
//调用aa页面中的创建box方法
function callParent(){
    parent.say();
}

</script>
</head>
<body>
<input type=button value="bb页面调用aa" οnclick="callParent()">
</body>
</html> 

其中,页面中使用的jquery需自行加载。

最后

以上就是整齐悟空最近收集整理的关于解决iframe中fixed失效问题的全部内容,更多相关解决iframe中fixed失效问题内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(129)

评论列表共有 0 条评论

立即
投稿
返回
顶部