gpt4 book ai didi

javascript - 使用javascript禁用iframe的重定向

转载 作者:行者123 更新时间:2023-12-03 18:08:57 31 4
gpt4 key购买 nike

我有重定向的 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>

最佳答案

您可以通过向请求添加请求 header 来实现,然后检查该 header 的 htaccess 文件,如果 header 不存在则进行重定向。

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

关于javascript - 使用javascript禁用iframe的重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32794358/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com