js弹窗返回值详解(window.open方式) |
test.php 复制代码 代码如下: <!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-Language" content="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="脚本之家(MyZ)" /> <meta name="Copyright" content="脚本之家(MyZ)" /> <meta name="description" content="" /> <meta name="keywords"content="" /> <link rel="icon" href="" type="image/x-icon" /> <link rel="shortcut icon" href="" type="image/x-icon" /> <link href="" rel="stylesheet" type="text/css" /> <title></title> <script type="text/javascript"> <!-- function winOpen() { window.open ("test2.php", "", "height=400, width=400"); } --> </script> </head> <body> <textarea id="text1" name="text1"></textarea> <input type="button" value="submit" name="submit" onclick="javascript:winOpen();" /> </body> </html> </body> </html> test2.php 复制代码 代码如下: <!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-Language" content="utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="author" content="脚本之家(MyZ)" /> <meta name="Copyright" content="脚本之家(MyZ)" /> <meta name="description" content="" /> <meta name="keywords"content="" /> <link rel="icon" href="" type="image/x-icon" /> <link rel="shortcut icon" href="" type="image/x-icon" /> <link href="" rel="stylesheet" type="text/css" /> <title></title> <script type="text/javascript"> <!-- function winBack() { if(window.opener) { fWindowText1 = window.opener.document.getElementById("text1"); fWindowText1.value = fWindowText1.value + "mayongzhan"; window.close(); } } --> </script> </head> <body> <input type="button" name="back" value="back" onclick="javascript:winBack();" /> </body> </html> window.open详解 window.open("sUrl","sName","sFeature","bReplace"); sUrl:可选项 。字符串(String) 。指定要被加载的HTML文档的URL地址 。假如无指定值,则about:blank的新窗口会被显示 。 sName:可选项 。字符串(String) 。指定打开的窗口的名字 。这个名字可以用于form或a对象的TARGET属性 。此名字也可以使用下列通用名称:_media:IE6.0在浏览器左边的媒体面板内打开sUrl 。 _blank:在新窗口中打开sUrl 。 sFeatures:可选项 。字符串(String) 。指定窗口装饰样式 。使用下面的值 。多个之间用逗号隔开 。只有当新的浏览器窗口被建立时,此参数的设置才会发生作用 。channelmode={yes|no|1|0}指定是否将窗口显示为频道模式 。默认值为no 。 directories={yes|no|1|0}指定是否显示「链接」按钮 。默认值为yes 。 返回值: 说明: 当sFeatures参数被指定时,没有在参数值的列表中出现的装饰样式都会被自动设置为no 。 IE5+中允许控制打开的窗口的标题栏 。通过在被信任的程序像Microsoft?VisualBasic或者HTML应用程式(HTA)中打开窗口可以关闭标题栏 。他们是可信任的因为他们使用Microsoft?InternetExplorer作为浏览器接口 。 当文档内的对象上的事件(event)激发的函数调用open方法时,window对象的open方法被使用 。而当文档内的对象上的事件(event)直接使用open方法时,document对象的open方法被使用 。 |