点击子页面元素加入到父页面表单中的实例

来源:互联网 发布:怎么在淘宝上开蛋糕店 编辑:程序博客网 时间:2024/06/04 23:32

父页面:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script language="javascript"> var child; function onClick () {  window.open('2.html','newwin','width=225,height=235,left=200,top=300,resizable=1,scrollbars=auto'); } function setData (id, name) {  document.getElementById('id').value = id;  document.getElementById('name').value = name; }</script></head><body> <p>id:<input type="text"  id="id"/></p>    <p>name:<input type="text" id="name" /></p>    <p><input type="button" value="弹出" onclick="onClick();" /></p></body></html>



子页面:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><script type="text/javascript">// Esc退出全屏      function exitFullScreenMe()          {              var esc=window.event.keyCode;              if(esc==27) //判断是不是按的Esc键,27表示Esc键的keyCode.              {               var url=document.location.href;                 win=window.open(url,'','fullscreen=0,directories=1,location=1,menubar=1,resizable=1,scrollbars=1,status=1,titlebar=1,toolbar=1'); //让新打开的窗口全屏                                window.opener=null;//出掉关闭时候的提示窗口    window.open('','_self');//ie7             window.close(); //先关闭老的窗口                                        }          }          document.onkeydown = exitFullScreenMe ; //当onkeydown(按键触发) 事件发生时调用hotkey函数</script></head><body> <table border="1">     <tr><th>id</th><th>name</th></tr>        <tr  onclick="opener.setData(this.childNodes[0].innerHTML, this.childNodes[1].innerHTML);window.close();"><td>1</td><td>Tony</td></tr>        <tr  onclick="opener.setData(this.childNodes[0].innerHTML, this.childNodes[1].innerHTML);window.close();"><td>2</td><td>Lily</td></tr>        <tr  onclick="opener.setData(this.childNodes[0].innerHTML, this.childNodes[1].innerHTML);window.close();"><td>3</td><td>John</td></tr>    </table></body></html>



原创粉丝点击