简单记录,是可以监控的,例子如下:
父页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<iframe id="child" src="chi.html" scrolling="no" frameborder="0"></iframe>
</body>
<script>
window.onload = function () {
var _iframe = document.getElementById('child').contentWindow;
var _div =_iframe.document.getElementById('button');
_div.style.backgroundColor = 'red';
_div.addEventListener("click",()=>{
console.log("ssaad");
})
}
</script>
</html>
子页面:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<button id="button">111</button>
</body>
</html>
网友评论