简体   繁体   English

如何在没有iframe的情况下在div中加载外部网址

[英]How to load the external url in div without iframe

I want to load external url in a div without using iframe/embed/object tag. 我想在不使用iframe / embed / object标记的情况下在div中加载外部网址。 I already used examples but it is not working 我已经使用了示例,但是没有用

For example: 例如:

$("#testDiv").load("//localhost:8000/cities/Mountain%20View/521/bottle-service/new");

or 要么

$("#testDiv").load("//www.xyz.com");

Could anyone please help me fix this issue? 谁能帮我解决这个问题?

Based on your comment I think you need something like this: 根据您的评论,我认为您需要以下内容:

$('#mydiv').load('http://localhost:8000/cities/Mountain%20View/521/bottle-service/new #testDiv', function(response, status, xhr) {
    if (status == "error") {
        var msg = "Sorry but there was an error: ";
        alert(msg + xhr.status + " " + xhr.statusText);
      }
});

For better insight I'm linking this question with this SO post 为了获得更好的见解,我将这个问题与帖子相关联

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM