window.opener的调用 2009/05/04 脚本杂文hidehai发表留言 window.opener 子页面调用上一页面的方法,需要在上一页面用windows.open()方法打开。 a.html <!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> <title> a </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <SCRIPT LANGUAGE="JavaScript"> <!-- function showMsg2(){ alert("I am in A,very comfortably!Let's go B"); window.open("b.html"); } //--> </SCRIPT> </head> <body> <INPUT TYPE="BUTTON" NAME="" VALUE="去B看看" Onclick="showMsg2()"> <A HREF="b.html">Let's go B! Go go go!</A> </body> </html> b.html <!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> <title>b </title> <meta name="generator" content="editplus" /> <meta name="author" content="" /> <meta name="keywords" content="" /> <meta name="description" content="" /> <SCRIPT LANGUAGE="JavaScript"> <!-- function showMsg(){ //alert("I am in B,very comfortably"); window.opener.showMsg2(); } //--> </SCRIPT> </head> <body> <INPUT TYPE="BUTTON" NAME="" VALUE="回忆下A" Onclick="showMsg()"> <A HREF="a.html">Let's go A! Go go go!</A> </body> </html> Related posts: js验证字符串为86开头的指定长度 使用DOM的核心方法生成段落和表格 javascript输出指定范围素数 简单div的隐藏显示代码