zoukankan      html  css  js  c++  java
  • Iframe------父子页面传值

    父页面给子页面传值

        father.jsp  父页面

          <body>

            <iframe src="你的子页面的jsp"                  
          width="500px" height="500px" name="iframeId"
          visibility="hidden" id="iframeId">
            </iframe>

            <form method="post" action="${pageContext.request.contextPath}/login" onsubmit="return login(this)" >
            输入用户名:<input type="text" name="userName" value="" id="name"/><br>
            密码:<input type="password" name="passWord" value="" id="password"><br>
          <input type="submit" value="提交" name="submit" >
            </form>
          </body>
          
          <script type="text/javascript">
           function login(form) {
         //获取本页面文本框的值
           var loginName=$("#name").val();
            var password=$("#password").val();
          //修改子页面中文本框的值
            $('#iframeId').contents().find("#loginName").val(loginName); //获取当前页面中id为iframeid的iframe,给子页面中id为loginName的文本框赋值
           $('#iframeId').contents().find("#password").val(password);
            $("#iframeId")[0].contentWindow.子页面函数的名字();
          }
          </script>


      zi.jsp 子页面
        
      <script type="text/javascript" src="js/jquery.min.js" ></script>
      <script type="text/javascript">
       function zi() {

       return true;
       }
      </script>
      <body>
       
        <form method="post" action="#" onsubmit="return zi()" >
         输入用户名:<input type="text" name="userName" value="" id="name"/><br>
         密码:<input type="password" name="passWord" value="" id="pass"><br>
         <input type="submit" value="提交" name="submit" >
        </form>

      </body>

  • 相关阅读:
    Silverlight Working with Sockets
    在Visual Studio 2010中使用gtest
    一个简单排序(就是传说中的冒泡)
    lucene锁与IndexModifier
    SQL Server 中的CTE递归查询
    利用Intelligencia.UrlRewriter.dll实现URL重写
    hibernate.cfg.xml详解
    WCF能干什么?
    C# 生成PDF
    MS SQL Server查询优化方法
  • 原文地址:https://www.cnblogs.com/xp0813/p/11746146.html
Copyright © 2011-2022 走看看