我有一个网页,其外部网页加载在<对象>标签
<!DOCTYPE html>
<html>
<head>
<title>Page title</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"> </script>
<script>
$(document).ready( function() {
var t = $("#wrapper").html();
alert(t);
});
</script>
</head>
<body>
<div id="wrapper">
<object id="embSite" type="text/html" data="includediv.htm" width="100%" height="600px" style="overflow:auto;border:5px ridge blue">
</object>
</div>
</body>
</html>
我的includediv.htm有以下内容:
<div id="includedDiv">This is the included page</div>
在我的警报中,我只获取了object标签的html,但没有获得includediv.htm的内容。如何从外部页面访问这些元素?
答案 0 :(得分:3)
你可以在下面的html内容中找到元素:
$.get(yourlink, function (data) {
var fullHTML = data;
$(fullHTML).find('#includedDiv').html();
}