Close window without the prompt message

Close window without the prompt message in IE7
If you tried to close a window using javascript window.close() method in IE7, and as you may noticed a message will prompt “The Webpage you are viewing is trying to close the window. Do you want to close this window”.

Because of the security enhancements in IE7, you can’t close a window unless it is opened by a script. so the walkaround will be to let the browser thinks that this page is opened using a script then closing the window. below is the implementation.

Create a javascript function which will be called to close the window

<script language=javascript>

function CloseWindow()

the code in bold is used to open a window in this case it’s not defined into the current window. In this way, we let the browser thinks that the current window is opened using javascript, so when the window.close() is executed it will close it without the message being displayed.

Now you can try it by adding the below HTML code,

<a href=”” onclick=”CloseWindow();”>Testing Close Window</a>

Hope this post will help you.

Below is the example to close the parent window closing while chid get opend,

var win (“URL”,”TITLE”,”width=1200,height=740,location=no”);
win.resizeTo(1200, 870);”,’_self’,”);

Core JavaScript

JavaScript is a scripting language widely used for client-side web development. It was the originating dialect of the ECMAScript standard. It is a dynamic, weakly typed, prototype-based language with first-class functions. JavaScript was influenced by many languages and was designed to look like Java, but be easier for non-programmers to work with.

JavaScript, despite the name, is essentially unrelated to the Java programming language, although both have the common C syntax, and JavaScript copies many Java names and naming conventions. The language’s name is the result of a co-marketing deal between Netscape and Sun, in exchange for Netscape bundling Sun’s Java runtime with their then-dominant browser. The key design principles within JavaScript are inherited from the Self and Scheme programming languages.

The more information on Javascript is available from the Javascript Bible is available as a PDF to download,

Core Javascript Bible