Commit 41c68210 authored by Allencl's avatar Allencl

1

parent f3d75ec4
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit" />
<!-- <title>精工底盘运营管理</title> -->
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/animate.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<!-- <script type="text/javascript" src="js/common.js"></script> -->
<!-- <script type="text/javascript" src="js/wow.js"></script> -->
<!-- <script>new WOW().init();</script> -->
</head>
<body>
<div>
<iframe id="myiframe1" style="width: 800px;height: 800px;border: 2px solid red;" src="./index22.html" frameborder="0"></iframe>
<iframe id="myiframe2" style="width: 800px;height: 800px;border: 2px solid red;" src="./index33.html" frameborder="0"></iframe>
</div>
<script>
$(document).ready(function() {
// 父页面
// 向第一个子页面 发消息
var iframe1 = document.getElementById('myiframe1').contentWindow;
var _json1={
a:1,
b:2,
c:3,
}
setTimeout(()=>{
iframe1.postMessage(JSON.stringify(_json1), '*');
},1000)
// 向第二个子页面 发消息
var iframe2 = document.getElementById('myiframe2').contentWindow;
var _json2={
a:6666,
b:2777,
c:888,
}
setTimeout(()=>{
iframe2.postMessage(JSON.stringify(_json2), '*');
},3000)
});
</script>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit" />
<!-- <title>精工底盘运营管理</title> -->
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/animate.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<!-- <script type="text/javascript" src="js/common.js"></script> -->
<!-- <script type="text/javascript" src="js/wow.js"></script> -->
<!-- <script>new WOW().init();</script> -->
</head>
<body>
<div>
<h1 style="color: #fff;">第一个子页面</h1>
<h1 style="color: #fff;">数据</h1>
<h1 id="id111111" style="color: #fff;">数据</h1>
</div>
<script>
$(document).ready(function() {
// 子页面 监听父页面消息
window.addEventListener('message', function(event={}) {
const _data=JSON.parse( (event.data||"{}") )
// console.log( _data );
$("#id111111").html(JSON.stringify(_data))
}, false);
});
</script>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit" />
<!-- <title>精工底盘运营管理</title> -->
<link rel="stylesheet" type="text/css" href="css/common.css" />
<link rel="stylesheet" type="text/css" href="css/animate.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<!-- <script type="text/javascript" src="js/common.js"></script> -->
<!-- <script type="text/javascript" src="js/wow.js"></script> -->
<!-- <script>new WOW().init();</script> -->
</head>
<body>
<div>
<h1 style="color: #fff;">第二个子页面</h1>
<h1 style="color: #fff;">数据</h1>
<h1 id="id22222" style="color: #fff;">数据</h1>
</div>
<script>
$(document).ready(function() {
// 子页面 监听父页面消息
window.addEventListener('message', function(event={}) {
const _data=JSON.parse( (event.data||"{}") )
// console.log( _data );
$("#id22222").html(JSON.stringify(_data))
}, false);
});
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment