Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript iframe src url无意中更改父url_Javascript_Jquery_Iframe_Cross Domain - Fatal编程技术网

Javascript iframe src url无意中更改父url

Javascript iframe src url无意中更改父url,javascript,jquery,iframe,cross-domain,Javascript,Jquery,Iframe,Cross Domain,我们正在通过iframe从我们的网站(www.example.com)调用api服务器(api.example.com) 当我们进行调用时,iframe源url将父窗口url更改为iframe源url。以下是iframe代码: <iframe onload="iframeManager.tempIframeCallback()" id="xd_iframe" allowtransparency="true" frameborder="0" scrolling="no" tabindex="

我们正在通过iframe从我们的网站(www.example.com)调用api服务器(api.example.com)

当我们进行调用时,iframe源url将父窗口url更改为iframe源url。以下是iframe代码:

<iframe onload="iframeManager.tempIframeCallback()" id="xd_iframe" allowtransparency="true" frameborder="0" scrolling="no" tabindex="0" name="xd_iframe" style="position:absolute;top:-9999em;width:10px;height:10px;" src= "{{html on api server}}">
        </iframe>

以下是api服务器上的html:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
        <title>xyz</title>

  <body>
    <script type="text/javascript" charset="utf-8">
        document.domain='example.com';
    </script>
  </body>
</html>

xyz
document.domain='example.com';

参考资料:

你提到的那篇文章是2005年写的!现在,大多数现代浏览器都支持CORS,只要服务器允许,CORS允许您干净地执行跨源AJAX。这里有一篇博文解释了这一点:

你提到的这篇文章是2005年写的!现在,大多数现代浏览器都支持CORS,只要服务器允许,CORS允许您干净地执行跨源AJAX。这里有一篇博文解释了如何使用iframe:

为什么要使用iframe?为什么不调用ajax来加载页面/数据?为什么要使用iFrame?为什么不调用ajax来加载页面/数据?