【问题标题】:How to load the external url in div without iframe如何在没有 iframe 的情况下在 div 中加载外部 url
【发布时间】:2017-09-20 01:19:09
【问题描述】:

我想在不使用 iframe/embed/object 标签的情况下在 div 中加载外部 url。我已经使用了示例,但它不起作用

例如:

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

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

谁能帮我解决这个问题?

【问题讨论】:

  • 定义“它不工作”
  • 你想加载什么?如果要渲染外部网站,则必须使用 iframe。如果你想做一个 AJAX 请求,这并不重要。那是什么?
  • 我想在我的页面中加载外部 url。它可能是我自己网站的 url 或外部网站页面(url)...但仅在 div 标签内..

标签: javascript jquery angularjs


【解决方案1】:

根据您的评论,我认为您需要这样的东西:

$('#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);
      }
});

为了更好地了解我将这个问题与this SO 帖子联系起来

【讨论】:

  • 我只需要在 div 标签中实现。我已经这样做了,但我的客户对 iframe/object 标签不满意。我需要知道如何只在 div 标签中实现外部 url。
  • 好的,我已经更新了我的答案,我认为这肯定会为你解决问题:)
  • 你可以接受我的回答> stackoverflow.com/help/someone-answers
猜你喜欢
  • 2019-04-18
  • 2012-08-22
  • 2013-02-19
  • 2014-09-17
  • 2011-11-09
  • 2013-01-06
  • 1970-01-01
  • 1970-01-01
  • 2015-11-23
相关资源
最近更新 更多