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

后端 未结 2 585
半阙折子戏
半阙折子戏 2021-02-04 11:25

Could anyone help me? Is it possible to code this? Redirect page inside iframe to another one but we must stay in iframe . Without influence to parent site. I tried many scripts

相关标签:
2条回答
  • 2021-02-04 12:07
    $(function() {
        if ('app' !== $('body').attr('id')){
            window.setTimeout(function(){
                window.top.location.href = 'your redirect url'; 
            }, 5000);
        }
    });
    

    in IFRAME use

    sandbox="allow-top-navigation allow-scripts allow-forms"
    
    0 讨论(0)
  • 2021-02-04 12:19

    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:

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

    JavaScript:

    window.frames["myFrame"].location = "http://..."
    
    0 讨论(0)
提交回复
热议问题