window.close() doesn't work - Scripts may not close windows that were not opened by script.
2014-11-21 17:38
495 查看
Summary
Closes the current window, or a referenced window.
Syntax
window.close();[/code]
Description
When this method is called, the referenced window is closed.This method is only allowed to be called for windows that were opened by a script using thewindow.open method.
If the window was not opened by a script, the following error appears in the JavaScript Console:
Scripts may not close windows that were not opened by script.
Examples
Closing a window opened with window.open()
<script type="text/javascript"> //Global var to store a reference to the opened window var openedWindow; function openWindow() { openedWindow = window.open('moreinfo.htm'); } function closeOpenedWindow() { openedWindow.close(); } </script>[/code]
Closing the current window
<script type="text/javascript"> function closeCurrentWindow() { window.close(); } </script>
相关文章推荐
- [乐意黎原创] window.close()提示 "Scripts may close only the windows that were opened by it"
- window.close()提示 "Scripts may close only the windows that were opened by it"
- js 关闭页面(Scripts may close only the windows that were opened by it.)
- scripts may close only the windows that were opened by it 浏览器JS控制无法关闭当前页面
- JS倒计时结束关闭页面:Scripts may close only the windows that were opened by it.
- js点击关闭当前浏览器Scripts may close only the windows that were opened by it.
- Scripts may close only the windows that were opened by it
- Why is the window.close() works in IE browser but not FireFox? "Warning: Scripts may not close windo
- Fixing "The following VMware kernal modules have been found on your system that were not installed by the VMware installer."
- adb logcat filter doesn't work
- My Backspace Key doesn't work!
- When Element add attribute by the method "setAttribute",It can't work in IE
- 安装rhel5.4遇到的IO-APIC+timer doesn't work .
- ROOT: Why TStyle::SetStatFontSize() doesn't work?
- Phone may be running a version of iOS that is not supported by this version of Xcode.
- mysql check constraint doesn't work
- Fixing "The following VMware kernal modules have been found on your system that were not installed b
- iPhone may be running a version of iOS that is not supported by this version of Xcode
- topmargin=\"0\" doesn\'t work in Firefox?
- Application did not close the cursor or database object that was opened here 异常