如何将外部网页加载到html页面的div中 [英] How to load an external webpage into a div of a html page
本文介绍了如何将外部网页加载到html页面的div中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在不使用iframe
元素的情况下将响应性网站加载到HTML页面的div中.
I need to load a responsive website into a div in my HTML page without using an iframe
element.
我尝试了此链接;它适用于我在脚本中提到的单个页面URL.
I have tried this link; it's working for a single page URL, which I mentioned in the script.
$('#mydiv').load('http://localhost/qa/ask#external-div', function(response, status, xhr) {
if (status == "error") {
var msg = "Sorry but there was an error: ";
alert(msg + xhr.status + " " + xhr.statusText);
}
});
推荐答案
使用简单的html,
<div>
<object type="text/html" data="http://validator.w3.org/" width="800px" height="600px" style="overflow:auto;border:5px ridge blue">
</object>
</div>
还是jquery,
<script>
$("#mydiv")
.html('<object data="http://your-website-domain"/>');
</script>
JSFIDDLE DEMO
这篇关于如何将外部网页加载到html页面的div中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文