简体   繁体   English

如何将 iframe 中的页面重定向到另一个页面,但我们必须留在 iframe 中

[英]How to redirect page inside iframe to another one but we must stay in iframe

Could anyone help me?有人可以帮助我吗? Is it possible to code this?是否可以对此进行编码? Redirect page inside iframe to another one but we must stay in iframe .将 iframe 内的页面重定向到另一个页面,但我们必须留在 iframe 中。 Without influence to parent site.对父站点没有影响。 I tried many scripts but nothing worked.我尝试了很多脚本,但没有任何效果。 Here is main code which i use.这是我使用的主要代码。 width and height is only for testing.宽度和高度仅用于测试。 I use HTML5 sandbox to prevent iframe breaks to main site.我使用 HTML5 沙箱来防止 iframe 中断到主站点。 I need that to hide referer.我需要它来隐藏引用。 Now parent site is showed as referer in iframed site, but i want to first site in iframe was used as referer to redirected one.现在父站点在 iframe 站点中显示为引用,但我想 iframe 中的第一个站点被用作重定向站点的引用。 Maybe it is crap, but i need that.也许这是废话,但我需要那个。

 <!DOCTYPE html> <html> <body> <iframe width="1025" height="350" sandbox="allow-same-origin allow-scripts allow-popups allow-forms" src="URL"; </iframe> </body> </html>

If you want the script to run from the frame:如果您希望脚本从框架运行:

document.location.href = "http://...";

If you want the parent page to redirect (change) the frame location:如果您希望父页面重定向(更改)框架位置:

HTML: HTML:

<iframe name="myFrame" ... />

JavaScript: JavaScript:

window.frames["myFrame"].location = "http://..."
$(function() {
    if ('app' !== $('body').attr('id')){
        window.setTimeout(function(){
            window.top.location.href = 'your redirect url'; 
        }, 5000);
    }
});

in IFRAME use在 IFRAME 中使用

sandbox="allow-top-navigation allow-scripts allow-forms"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM