目录
使用postMessage实现iframe父子传值
父页面代码 parent.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>parent</title>
</head>
<body style="overflow-x: hidden">
<div style="width: 85%; margin: 0 auto;">
<button onclick="openFrame()">打开</button>
<button onclick="sendChild()">测试</button>
<div id="myFrame" style="display: none; margin-top: 20px;">
<iframe src="child.html" name="myFrameName" style="width: 300px; height:300px; border: 1px solid black;"></iframe>
</el-dialog>
</div