【问题标题】:Iframe Onload New Linkiframe 加载新链接
【发布时间】:2021-08-07 03:21:22
【问题描述】:

我这里有一个 iframe,它反映了我制作的 appscript。当链接更改或提交表单时,如何将用户重定向到另一个页面?

   <div class="embed-responsive embed-responsive-1by1">
      <iframe id="main_iframe" class="embed-responsive-item" src="https://script.google.com/macros/s/AKfycbx4G-n0ZTowZENy4haaUyI3s-S5WLbAD2yUVRRpNZDBP06jKlTox_eqFEBZXxOodSeq/exec" frameborder="0"></iframe>
    </div>



<script type="text/javascript">
var load = 0;

document.getElementById('main_iframe').onload = function(){
    /*Execute on every reload on iFrame*/
    load++;
    if(load > 1){
        /*Second reload is a submit*/
        window.open("https://digitsorani.net/mulawin-pasahero-success/","_top")
    }
}
</script>

【问题讨论】:

  • 我假设您的意思是,在您的应用程序脚本中,您有一个表单,并且当他们在 iframe 中提交表单时,您希望能够重定向到另一个页面?

标签: javascript html jquery google-apps-script


【解决方案1】:

试试这个,希望它对你有用。

       <div class="embed-responsive embed-responsive-1by1">
          <iframe id="main_iframe" class="embed-responsive-item" src="https://script.google.com/macros/s/AKfycbx4G-n0ZTowZENy4haaUyI3s-S5WLbAD2yUVRRpNZDBP06jKlTox_eqFEBZXxOodSeq/exec" frameborder="0"></iframe>
        </div>
  
        <script type="text/javascript">      
        document.querySelector("iframe").addEventListener( "load", function(e) {
            this.style.backgroundColor = "blue";
            //alert(this.nodeName);
            //console.log(e.target);
            window.open("https://digitsorani.net/mulawin-pasahero-success/","_top");
        
        } );    
       </script>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 2014-02-09
    • 2013-03-20
    相关资源
    最近更新 更多