-1

我正在使用此代码http://www.solstas.com/find-a-location/显示iframe

<iframe src="http://www.solstas.com/find-a-location/" width="837" height="544"> 
</iframe>

而这段代码使用jquery:

$("#siteloader").html('<object data="http://www.solstas.com/find-a-location/">');

但它没有显示任何东西,我尝试了其他网站然后它工作。有人说这可能是因为该站点设置了 X-Frame-Options。

请帮忙。

4

3 回答 3

1

You're not going to be able to frame this, because the site uses X-Frame-Options. I did this request:

GET /find-a-location HTTP/1.1
Host: www.solstas.com

And got this response:

HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 176
Content-Type: text/html; charset=utf-8
Location: /error/internal-server-error?aspxerrorpath=/find-a-location
Server: Microsoft-IIS/7.5
X-Umbraco-Version: 4.7
Set-Cookie: UserLatitude=29.8301; path=/
Set-Cookie: UserLongitude=-95.4739; path=/
X-Powered-By: ASP.NET
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Date: Fri, 14 Mar 2014 06:15:15 GMT

<html><head><title>Object moved</title></head><body>
<h2>Object moved to <a href="/error/internal-server-error?aspxerrorpath=/find-a-location">here</a>.</h2>
</body></html>

The X-Frame-Options: SAMEORIGIN means this page shouldn't be displayed in a frame, including an iframe. Practically speaking, it means you can't do it, because pretty much all modern browsers will obey this request.

于 2014-03-14T06:18:16.017 回答
1

你可以试试:

 $("#siteloader").append($('<iframe width="837" height="544" src="http://www.solstas.com/find-a-location/"></iframe'));
于 2014-03-14T05:52:24.780 回答
0

这是将源代码加载iframe到 jquery的代码

$(document).ready(function() {
    $('#iframe').attr('src', 'http://www.solstas.com/find-a-location/');
});

注意:如果该域(www.solstas.com)允许跨域框架,这将起作用

于 2014-03-14T05:56:08.837 回答