<div class="cont">
<iframe id="iframe" sandbox="" src="external_website" width="100%" height="100%" frameborder="0"></iframe>
</div>
我想用JQuery检测我是否从iframe中的其他网站获得了内容?
我尝试了不同的东西,没有任何帮助。 感谢。
答案 0 :(得分:-1)
$("#myiframe").contents().find("#myContent")
<html>
<head>
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<script type="text/javascript">
$(function() {
//here you have the control over the body of the iframe document
var iBody = $("#iView").contents().find("body");
//here you have the control over any element (#myContent)
var myContent = iBody.find("#myContent");
});
</script>
</head>
<body>
<iframe src="mifile.html" id="iView" style="width:200px;height:70px;border:dotted 1px red" frameborder="0"></iframe>
</body>
</html>