2015-04-03 108 views
0

我有两个页面(index.html和main.html)。这是index.html的body标签:使用window.close关闭窗口

<a href="main.html">main page</a> 

,并在主网页我有一个按钮,当点击该按钮我想关闭这个窗口,但此功能不能正常工作!我如何做到这一点?在控制台给予这样的警告:

Scripts may close only the windows that were opened by it. 
+0

并没有打开的窗口? – adeneo 2015-04-03 20:37:54

+0

'function(window.close)'是一个语法错误 – dandavis 2015-04-03 20:39:10

+1

1)它是window.close()和2)你只能关闭你用脚本自己打开的东西 – mplungjan 2015-04-03 20:39:23

回答

0

这应该关闭该窗口:

<form> 
<input type="button" value="Close Window" onClick="window.close()"> 
</form> 
0
$('closeButton').click(function(){ 

    window.close(); //only if you opened the window, and are the owner will this work! 

});