demo.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body,html {
margin: 0px;
padding: 0px;
width: 100%;
height: 100%;
}
iframe {
width: 100%;
height: 100%;
}
</style>
<script>
window.onload = function() {
var iframe = document.getElementsByTagName("iframe")[0];
var win = iframe.contentWindow; // 通过contentWindow获取ifame子页面的window窗体对象。(不允许跨域名访问)
console.log(win);
var iframeDocument = iframe.contentWindow.document;
var input1 = iframeDocument.getElementById("id1");
input1.onblur = function() {
alert(11);
}
}
</script>
</head>
<body>
<iframe src="aa.html" frameborder="0"></iframe>
</body>
</html>