问题描述
我有一个在nodejs上运行的angular js应用程序.我想加载一个外部站点,该外部站点也是我的应用程序,它在加载模板URL的同时在不同的IP上运行,并带有一个div.因此,在模板网址中,我提到了一个HTML文件.我在HTML文件中这样写.
I have one angular js application which is running on nodejs. I want to load an external site, the external site is also my application which is running on different IP, with-in a div while loading the template url. So in template url I mentioned one HTML file. Inside that HTML file I had written like this.
<iframe src="myexternalurl"></iframe>
但是在错误控制台中,它是这样的:
But in error console it is coming like:
Refused to display 'myexternalurl' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
推荐答案
您可以简单地将以下行添加到外部站点中的 .htaccess
中(如果您的应用程序是这样的话)
You can simply add following line to .htaccess
in your external site (If its your application)
Header always unset X-Frame-Options
如果要允许某些特定站点.请参阅下面的链接
If you want to allow some specific site. refer the below link
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/X-Frame-Options
这篇关于Angular js在iframe中加载外部网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!