zoukankan      html  css  js  c++  java
  • 模式窗体中调用父页面js与非模式化调用非父页面的js方法

    最近项目中使用模式窗体,遇到以下问题记录一下:

    模式窗体:你必须关闭该窗体,才能操作其它窗体;比如说,必须按确定或取消,或者按关闭。

    非模式窗体:不必关闭该窗体,就可转换到其它窗体上进行操作。




    一:非模式化窗体就是用
    1.var val = parent.document.getElementById("txt1");   
    var val = parent.document.getElementById("txt1");
    

      

    二:模式窗体

    1. parent.html 
      <html>
      <head>
      <script language="text/javascript">
      function openwindow(){
         //这个父页面通过 retval获取子页面的window.returnValue返回来的值
          retval=window.showModalDialog("child.html")
          Alert(retval);
          document.getElementById('text1').value=retval
      }
      
      function Alert(msg){
          alert(msg);
      }
      </script>
      </head>
      <body>
      <form name=frm>
      <input name=text1 type=text id="text1"/>
      <input type=button onclick="javascript:openwindow()" value="Open window..">
      </form> 
      </body>
      </html>
      

        2. child.html

      <html>
      <head>
      <script language="javascript">
      function changeparent(){
        //通过window.returnvalue把值返回父页面
          window.returnValue="Value changed.."
          window.close()
      }
      </script>
      </head>
      <body>
      <form>
      <input type=button onclick="javascript:changeparent()" value="Change main window’s textbox value..">
      </form>
      </body>
      </html>
  • 相关阅读:
    Hive和HBase的区别
    HBase面试问题
    HBase的rowkey的设计原则
    一、spark 数据类型(Data Types)
    Phaser显示对象(文字)
    Phaser中的组对象group
    Phaser中的动画
    phaser.js 显示对象笔记
    MD5之C#密码加密备忘录
    学了点小小的技巧,也有一点点问题,怎么解决呢?
  • 原文地址:https://www.cnblogs.com/panmy/p/5238784.html
Copyright © 2011-2022 走看看