真奇怪,opener象我这样用怎么就不行呢?我的用法是这样的:
第一个网页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head> <body>
<a href="d2.htm" target="_blank">link </a>
<form name="form1" method="post" action="">
<input type="text" name="txt1">
</form> </body>
</html>
第二个网页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function aa(){opener.document.form1.txt1.value="abcdefg";} </head>
</script>
<body>
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Button" onClick="aa()">
</form> </body>
</html>
大意就是先第一个网页通过链接打开第二个网页,然后第二个网页用按钮调用含opener的函数来对第一个网页的文本框赋值。
调用后却显示错误,我该怎么做呢?
有位朋友在前面回复应该把<a....>改为a href="#" onclick="window.open('d2.htm','loginnewman')">link </a>
发现没有用,是否不太准确。应该这个问题不是很难吧,越是不知,我越想知道,帮我走出迷途好不好。
第一个网页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head> <body>
<a href="d2.htm" target="_blank">link </a>
<form name="form1" method="post" action="">
<input type="text" name="txt1">
</form> </body>
</html>
第二个网页:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function aa(){opener.document.form1.txt1.value="abcdefg";} </head>
</script>
<body>
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Button" onClick="aa()">
</form> </body>
</html>
大意就是先第一个网页通过链接打开第二个网页,然后第二个网页用按钮调用含opener的函数来对第一个网页的文本框赋值。
调用后却显示错误,我该怎么做呢?
有位朋友在前面回复应该把<a....>改为a href="#" onclick="window.open('d2.htm','loginnewman')">link </a>
发现没有用,是否不太准确。应该这个问题不是很难吧,越是不知,我越想知道,帮我走出迷途好不好。
第二个文件</script>和</head>的位置不对<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head> <body>
<a href="javascript:window.open('d2.htm');void(0);">link </a>
<form name="form1" method="post" action="">
<input type="text" name="txt1">
</form> </body>
</html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function aa(){
opener.document.form1.txt1.value="abcdefg";
}
</script>
</head>
<body>
<form name="form1" method="post" action="">
<input type="button" name="Button" value="Button" onClick="aa()">
</form> </body>
</html>