iframe传值
<body>
<button onclick="openDetails()">click</button>
<iframe src="popup.html" frameborder="0" id="details-popup" name="detailsPopup"></iframe>
<script>
function openDetails(popData){
$("#details-popup").css("display","block");
var popData =“this is pop value”;
detailsPopup.window.document.getElementById("popup-data").value=popData;
// 初始化弹窗
detailsPopup.window.init();
}
</script>
</body>
子iframe
<input type="text" id="popup-data" style="display:none;"/>
iframe 监听鼠标点击事件
<iframe src="close.png" frameborder="0" id="iFrame" width="500px" height="500px" style="background: red;"></iframe>
<script>
var iframe = document.getElementById('iFrame');
iframe.onload = function() {
//iframe.contentDocument
//contentDocument 属性以 HTML 对象返回框架容纳的文档。
//可以通过所有标准的 DOM 方法来处理被返回的对象
iframe.contentDocument.onclick = function () {
alert("d");
};
}
</script>