标签:get width charset htm mes frame com false idt
<html>
<head>
<title>test</title>
<style>
iframe{
border: 1px solid red;
}
</style>
</head>
<body>
<iframe src="./content.html" frameborder="0" id=‘receiver‘></iframe>
<script>
window.onload = () => {
var receiverWindow = document.getElementById(‘receiver‘).contentWindow;
receiverWindow.postMessage(‘hello‘,‘*‘)
}
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<p>postmessage</p>
<script>
window.addEventListener(‘message‘,function(e){
console.log(‘message is ok‘,e.data);
},false)
</script>
</body>
</html>
标签:get width charset htm mes frame com false idt
原文地址:https://www.cnblogs.com/l8l8/p/11138554.html