我收到此错误:
Refused to display 'http://instagram.com/p/page/' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
我想在我的网页中显示Instagram页面,因为它是一个移动应用程序,我想使用我的后退按钮。
这是我的网页:
<body id="responsiveDemo">
<div data-role="page" id="test" data-theme="g">
<div data-theme="g" data-role="header">
<a href="javascript:history.back()" data-icon="back" data-iconpos="notext"></a>
<h1>Instagram</h1>
</div>
<div data-role="content">
<iframe id="iframeInstagram" src="" name="IframeInstagram" style="width: 100%; height: 1000px; border: medium none;visibility: visible;"></iframe>
<script>
var query = location.search.substring(1);
//console.log(query);
var parameters = {};
var keyValues = query.split(/&/);
for (var i = 0; i < keyValues.length;i++) {
var keyValuePairs = keyValues[i].split(/==/);
var key = keyValuePairs[0];
var value = keyValuePairs[1];
parameters[key] = value;
}
/*+$(document).ready(function() {
//console.log(parameters['page']);
document.getElementById('iframeColaborador').src = parameters['colaborador'];
});
*/
//$(document).on("pageload", '#test', function() {
$(document).on("pageshow", '#test', function() {
//$(document).load(function() {
console.log(parameters['instagram']);
document.getElementById('iframeInstagram').src = parameters['instagram'];
//document.getElementById('iframeNews').src = 'http://www.unican.es';
});
</script>
</div> <!-- /content -->
我正在使用这个网页来展示其他网站,但我不知道为什么它失败了。
是的,您可以使用此格式显示Instagram页面
http://instagram.com/p/qbq6fIJMVZ
...在iframe中,只要你添加后缀/embed
就好
<iframe width="320" height="440" src="http://instagram.com/p/qbq6fIJMVZ/embed" frameborder="0"></iframe>
你将无法,因为Instagram拒绝外部网站将他们的网站放在框架中。这就是为什么你得到关于X-Frame-Options
被设置为SAMEORIGIN
的错误消息 - 同样的来源意味着它只允许Instagram使用框架,而不是其他人。
首先,Instagram允许您嵌入您所做的股票。你所要做的就是
1-open instagram from your web browser 2-click any share you have 3-at right bottom there is hidden menu with shape of ... (3 dot) click it 4-select second menu which is embed to website 5-click copy link from the next page and use that code to use instagram embeded link at your page
如果你发现它很困难,或者你想在这里使用纯代码,那么你必须使用自己的网址使用下面的代码
<blockquote class="instagram-media" data-instgrm-version="7" >
<a href="https://www.instagram.com/p/BT8cmZRlkVJ/"></a>
</blockquote>
<script async defer src="//platform.instagram.com/en_US/embeds.js"></script>