本文实例讲述了javascript弹出页面回传值的方法。分享给大家供大家参考。具体实现方法如下:
a1.html
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Window 1 </TITLE>
</HEAD>
<BODY>
<H1>Window 1</H1>
<INPUT TYPE="text" NAME="a">
<INPUT TYPE="button" ONCLICK="return test();" >
<script>
function test(){
window.open('b1.html','newwindow','height=100,width=400') ;
}
</script>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> Window 1 </TITLE>
</HEAD>
<BODY>
<H1>Window 1</H1>
<INPUT TYPE="text" NAME="a">
<INPUT TYPE="button" ONCLICK="return test();" >
<script>
function test(){
window.open('b1.html','newwindow','height=100,width=400') ;
}
</script>
</BODY>
</HTML>
b1.html
复制代码 代码如下:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<H1>Window 2</H1>
<INPUT TYPE="text" NAME="b" value="11"><INPUT TYPE="submit" ONCLICK="return test();">
<script>
function test(){
var bValue = 111;
window.opener.a.value = bValue ;
window.close();
}
</script>
</BODY>
</HTML>
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<H1>Window 2</H1>
<INPUT TYPE="text" NAME="b" value="11"><INPUT TYPE="submit" ONCLICK="return test();">
<script>
function test(){
var bValue = 111;
window.opener.a.value = bValue ;
window.close();
}
</script>
</BODY>
</HTML>
希望本文所述对大家的javascript程序设计有所帮助。