如何将外部网页加载到html页面的div中

如何将外部网页加载到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

JSFIDDLE DEMO