方法一: 此方法在IE7中测试通过。Firefox没通过 <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title>无提关闭窗</title> </head> <body> <script language="JavaScript" type="text/javascript"> function Close() { //关闭当前窗口 window.open('','_parent',''); window.close(); } function OpenWin(url) { //全屏打开窗口,网址 url window.open(url,'_blank','fullscreen=1'); Close(); } </script> <input type="button" value="关闭" onclick="Close();"/> </body> </html> 方法二: 1·把下面这段代码加到你要执行关闭IE窗口的那桢上: getURL("javascript:window.opener=null;window.close();"); 2·把下面的代码加到你的那个按钮上: on(release){ getURL("javascript:window.opener=null;window.close();"); } 这种不能直接关闭原来点IE打开的窗口的! <object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"> </object> <input type="button" name="Button" value="关闭窗口" onClick="document.all.WebBrowser.ExecWB(45,1)"> 方法三: 在不是js打开的页面上按window.close(),会有提示框,很烦,现在可以不用了,没有提示框直接关闭窗口。 试试下面代码: <object id=WebBrowser width=0 height=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2> </object> <input type=button name=Button value=关闭窗口 onClick=document.all.WebBrowser.ExecWB(45,1)> 试着改变参数会得到其他一些功能: WebBrowser.ExecWB(1,1) 打开 WebBrowser.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口 WebBrowser.ExecWB(4,1) 保存网页 WebBrowser.ExecWB(6,1) 打印 WebBrowser.ExecWB(7,1) 打印预览 WebBrowser.ExecWB(8,1) 打印页面设置 WebBrowser.ExecWB(10,1) 查看页面属性 WebBrowser.ExecWB(15,1) 好像是撤销,有待确认 WebBrowser.ExecWB(17,1) 全选 WebBrowser.ExecWB(22,1) 刷新 WebBrowser.ExecWB(45,1) 关闭窗体无提示 这些只对IE5.5以上版本有效,我是在IE6下测试的,通过的。 |