// ==UserScript==
// @name Check window.close
// @author TarquinWJ 
// @namespace http://www.howtocreate.co.uk/ 
// @version 1.0
// @description  Prevents malicious sites from closing windows that
//			they did not open, or do not have permission to
//			close.
// @ujs:category browser: fixes
// @ujs:published 2005-06-16 22:46
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/browser/fixes/check-window-close 
// @ujs:download http://userjs.org/scripts/download/browser/fixes/check-window-close.js
// ==/UserScript==


/* 
 * Please see
 * http://www.howtocreate.co.uk/operaStuff/userJavaScript.html#terms
 * for License and Terms of Use
 */

(function () {
	var oClose = window.close, canClose = window.opener; //get it before someone overwrites it so they can use the IE bug
	window.close = function () {
		if( canClose || window.confirm('The Web page you are viewing is trying to close the window.\n\nDo you want to close this window?') ) {
			oClose();
		}
	};
})();
