使用javascript禁用iframe的重定向

时间:2015-09-26 06:32:08

标签: javascript .htaccess

我有重定向的htacess代码

http://website.com:352/pictures/1 to another page. 

如果请求在iframe src中,我想阻止此重定向。这可能吗?

<iframe src="http://website.com:352/pictures/1" style="border: none; width:100%; height:1100px;"></iframe>

1 个答案:

答案 0 :(得分:0)

您可以通过向请求添加请求标头,然后在htaccess文件中检查该标头,并在标头不存在时进行重定向。

但是,要向iframe添加请求标头,您需要通过创建AJAX请求并将结果附加到iframe来进行解决方法 您可以查看解答如何执行此操作的答案:How to set custom http headers when changing iframe src?