ajax学习篇7
关于window.Open的传值问题。 首先我们先了解一些open方法里面是属性 alwaysLowered | yes/no | 指定窗口隐藏在所有窗口之后
这里用例子讲解吧 <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type"content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript"> window.onload = function() { document.getElementById("button").onclick = function() { var obj = window; obj.name = "aa";//这里我们定义一个窗体元素 window.open("page.html",'my',"width=200,height=200");//第一个参数表示弹出的窗体的路径,其实后面是可以跟着参数的。第二个参数可以为空,表示当前窗体的米兹,第三个参数表示对弹出窗体的一些属性的设置。这样当我们点击按钮就可以跳转到其他指定窗口了。 } } </script> </head> <body> <input type="text"id="text1"> <input type="button"value="check" id="button"> </body> </html>
第二个page.html <!DOCTYPE html PUBLIC "-//W3C//DTDHTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type"content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript"> window.onload = function() { document.getElementById("button").onclick = function() { alert(opener.document.getElementById("text1").value);//opener里面包含父窗体的所有信息。 alert(opener.name);//这个表示父窗体的name,在上面自己随便设置的属性哦。 }; } </script> </head> <body> <a>你好</a> <input type="button"value="close" id="button"/> </body> </html> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |