父子页面传值
2013-12-16 12:52
197 查看
父页面:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>parent.html</title> <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","open other window",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()">please click it</a> <input type="hidden" name="name" id="hname"/> </body> </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); //调用父窗口的方法进行传值 window.opener = null; window.close(); } </script> </head> <body> 请选择名称:<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>
总结:这个在360浏览器中测试不理解,但在IE可以测试成功。在父页面中主要写入
window.open("child.html","open other window",style);
function setValue(name,hname)
在子页面中调用父类的方法
window.opener.setValue(name,hname); //调用父窗口的方法进行传值 window.opener = null; window.close();
相关文章推荐
- 用window.open方法实现子页面调用的父子页面传值
- jsp父子页面传值
- 使用MUI实现父子页面传值
- 用open或showModalDialog实现父子页面传值
- iframe-父子-兄弟页面相互传值(jq和js两种方法)
- 父子页面传值
- 用open或showModalDialog实现父子页面传值
- iframe-父子-兄弟页面相互传值(jq和js两种方法)
- iframe父子页面传值
- React native从入门到深入 ---页面传值,父子组件传值
- 父子页面传值的问题
- js父页面操作的父子页面传值
- C#--父子页面传值、刷新(showModalDialog)
- 父子页面相互传值
- (一)上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)
- 打开模式窗,在父子页面传值
- 上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)(1)
- (二)上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)
- 上传图片至服务器,写入到数据库Blob字段中,以及从数据库读取Blob信息(iframe父子页面传值)(2)
- iframe父子嵌套页面之间传值