posts - 241,  comments - 116,  trackbacks - 0

          我使用js在父子之間進(jìn)行傳值主要是通過(guò)在子窗口調(diào)用父窗口的方法來(lái)實(shí)現(xiàn)傳值的目的。

          parent.html

          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
            <head> jquery控制只能輸入數(shù)字并關(guān)閉輸入法和簡(jiǎn)單日歷控件


              <title>parent.html</title>
              
              <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
              <meta http-equiv="description" content="this is my page">
              <meta http-equiv="content-type" content="text/html; charset=UTF-8">
              
              <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
              <script type="text/javascript">
                  function openWin() {
                      var style = "width=300,height=400,location=no,directories=no,toolbar=no,status=no,menubar=no,resizable=no,scrollbars=no";
                      window.open("child.html","打開(kāi)窗口傳值",style);        
                  }
                  
                  function setValue(name,hname) {
                      document.getElementById("name").value = name;
                      document.getElementById("hname").value = hname;
                  }
              </script>
            </head>
           
            <body>
              name:<input type="text" id="name"/><a href="#" onclick="openWin()">請(qǐng)選擇</a>
              <input type="hidden" name="name" id="hname"/>
            </body>
          </html>
          child.html
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html>
            <head>
              <title>child.html</title>
              
              <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
              <meta http-equiv="description" content="this is my page">
              <meta http-equiv="content-type" content="text/html; charset=UTF-8">
              
              <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
              <script type="text/javascript">
                  function selectedThis(obj) {
                      var name = obj.value;
                      var hname = obj.id;
                      window.opener.setValue(name,hname);//調(diào)用父窗口的方法進(jìn)行傳值
                      window.opener = null;
                      window.close();
                  }
              </script>
            </head>
           
            <body>
              請(qǐng)選擇名稱:<br/>
              <input type="radio" name="name" id="name1" value="名稱1" onclick="selectedThis(this)"/>名稱1
              <input type="radio" name="name" id="name2" value="名稱2" onclick="selectedThis(this)"/>名稱2
              <input type="radio" name="name" id="name3" value="名稱3" onclick="selectedThis(this)"/>名稱3
              <br/>
              <input type="radio" name="name" id="name4" value="名稱4" onclick="selectedThis(this)"/>名稱4
              <input type="radio" name="name" id="name5" value="名稱5" onclick="selectedThis(this)"/>名稱5
              <input type="radio" name="name" id="name6" value="名稱6" onclick="selectedThis(this)"/>名稱6
              
            </body>
          </html>
          posted on 2011-08-03 09:52 墻頭草 閱讀(1524) 評(píng)論(2)  編輯  收藏

          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           
          人人游戲網(wǎng) 軟件開(kāi)發(fā)網(wǎng) 貨運(yùn)專家
          主站蜘蛛池模板: 绵阳市| 瓮安县| 桐梓县| 东乌| 云和县| 长沙市| 昌乐县| 鹤庆县| 江津市| 耒阳市| 东阿县| 清苑县| 峨山| 昭平县| 监利县| 永吉县| 东光县| 桂平市| 云林县| 隆回县| 台湾省| 甘孜县| 油尖旺区| 德保县| 汽车| 即墨市| 开平市| 喜德县| 达日县| 阿鲁科尔沁旗| 云阳县| 曲松县| 玉树县| 张家口市| 望奎县| 扶沟县| 菏泽市| 伊金霍洛旗| 漯河市| 河东区| 曲麻莱县|