首页 > 语言 > JavaScript > 正文

js弹窗返回值详解(window.open方式)

2024-05-06 14:30:43
字体:
来源:转载
供稿:网友

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的新窗口会被显示。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选