在iframe中加载其他域名网站 [英] Load another domain website in a iframe

查看:2121
本文介绍了在iframe中加载其他域名网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用iframe在我的网站上加载其他网站。

I want to load another website on my website using the iframe.

我在其他一些网站上使用iframe加载时遇到了一些其他问题。
所以我们不能实现iframe加载其他域名网页?如果是这样,我们是否有其他方式来加载网站

I have seen some other issues while loading using the iframe in some other websites. So can't we implement iframe to load other domain website pages? If so, do we have another way to load the websites?

以下是我测试的方式

我试过
http://www.w3schools.com/tags/tryit.asp? filename = tryhtml_iframe ,包含以下代码。

I have tried in http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe with the following code.

<!DOCTYPE html>
<html>
<body>
    <iframe src="https://github.com/mattlewis92/angular-bootstrap-calendar/issues" width="800" height="800">
      <p>Your browser does not support iframes.</p>
    </iframe>
</body>
</html>

我收到以下错误。
拒绝显示' https://github.com/mattlewis92/angular-bootstrap-calendar/issues '在一个框架中,因为祖先违反了以下内容安全策略指令:frame-ancestors'none'。

I got the following error. Refused to display 'https://github.com/mattlewis92/angular-bootstrap-calendar/issues' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'none'".

推荐答案

短答案是否定的,您无法使用iFrame嵌入此网站。

Short answer is NO, you cannot embed this site using iFrame.

如果网站允许,您的代码就可以了 - 但是在这种情况下,您没有有效的方法嵌入此网站。

If the site allowed it, your code is fine - however in this case you do not have a valid way to embed this site.


frame-ancestors指令指定可以使用和元素嵌入页面的有效父级

显然他们不希望你嵌入他们的网站:

Obviously they do not WANT you to embed their site:

本服务的外观和版权归©GitHub,Inc。所有。保留所有权利。未经GitHub明确书面许可,您不得复制,复制或重复使用HTML / CSS,Javascript或视觉设计元素或概念的任何部分。

The look and feel of the Service is copyright © GitHub, Inc. All rights reserved. You may not duplicate, copy, or reuse any portion of the HTML/CSS, Javascript, or visual design elements or concepts without express written permission from GitHub.






HOWEVER

您可以使用javascript来获取内容,因为他们的API 允许您这样做。

You can use javascript to get the content since their API allows you to do so.

尝试ajaxing https://api.github.com/repos/mattlewis92/angular-bootstrap-calendar/issues - 我看到 Access-Control-Allow-Origin:* 所以你可以在对你的页面的Ajax响应中返回它

Try ajaxing to https://api.github.com/repos/mattlewis92/angular-bootstrap-calendar/issues - I see Access-Control-Allow-Origin:* so you are able to return that in an Ajax response to your page

$(function() {
  $.get("https://api.github.com/repos/mattlewis92/angular-bootstrap-calendar/issues",function(data) {
    console.log(data)
    $("#result").html(data[0].title);
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div id="result"></div>

或写你的代理人n服务器使用

or write a proxy on your own server using

curl -i "https://api.github.com/repos/mattlewis92/angular-bootstrap-calendar/issues"

这篇关于在iframe中加载其他域名网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆