While I was working on some HTML files which requires closing the main window when I clicked on the close button which my application provided. I used window.close() javascript to close the browser window. It works perfectly fine under Internet Explorer 6 or lesser versions (<=IE6).

However the problem comes when I tested it on the IE7 and Netscape 7.0 and Netscape 7.1. IE7 gives me a prompt which is asking whether to close the window or not. The script is not at all functioning in the Netscape browser.

After a lot of research I came to know that the problem is that we are closing the window using the script which was not opened by the script. So I made changes to the code which opens some new file in the same window using the javascript.

The new file contains the window.close() method in its onload() method of BODY tag.So the code looks like this..

function closeWindow(){
var agt=navigator.userAgent.toLowerCase();
var pos = agt.indexOf('msie');
version = navigator.userAgent.substring(pos + 5).substring(0, 1);
if((agt.indexOf("msie") != -1) && (version 7)

This will works fine for the Internet Explorer v6 and above and Netscape v7 and above. The idea here is the browsers IE7 and Netscape support tabbed browsing so we cannot close them using window.close(). So we close the browser by opening a new file in the same window using script.

Like it on Facebook, Tweet it or share this article on other bookmarking websites.

Comments (0)

There are no comments posted here yet

What is the main gadget on our body in present days?

main gadget
No answer selected. Please try again.
Please select either existing option or enter your own, however not both.
Please select minimum 0 answer(s) and maximum 4 answer(s).
[{"id":"21976","title":"Ipad","votes":"8","type":"x","order":"1","pct":9.52,"resources":[]},{"id":"21977","title":"Laptop","votes":"14","type":"x","order":"2","pct":16.67,"resources":[]},{"id":"21978","title":"Mobile","votes":"57","type":"x","order":"3","pct":67.86,"resources":[]},{"id":"21979","title":"Desktop","votes":"5","type":"x","order":"4","pct":5.95,"resources":[]}] ["#ff5b00","#4ac0f2","#b80028","#eef66c","#60bb22","#b96a9a","#62c2cc"] ["rgba(255,91,0,0.7)","rgba(74,192,242,0.7)","rgba(184,0,40,0.7)","rgba(238,246,108,0.7)","rgba(96,187,34,0.7)","rgba(185,106,154,0.7)","rgba(98,194,204,0.7)"] 350
bottom 200
No married couple wants to end up getting divorced. It is not like they have planned for it. They try to put up with their partners for as long as they
Due to our modern lifestyle, we feel that digestion related disorders are a common problem. Thus, we neither give importance to them nor seek any help
The bond of marriage brings the two people together. Initially, everything may seem okay and both of them slowly start discovering each other in the journey.
Why to choose Java? In the computer market, being able to use Java is a crucial knowledge. Java is a development terminology used to build compelling
DATABASE CONNECTIVITY This articles explains the need of database connectivity, the way it is achieved through Java using the JDBC(java database connectivity)
  Write your first simple java program.   First of all we need is a placewhere we can write your Java code. All Java programs are written using
Array of objects in Java Arrays are defined as block of continous memory locations which are arranged in one after another. Elements of the Array can
Synchronized block is alternative mechanism for "synchronized" methods.If we inherihate the non synchronized blocks either from base class or interface