Solved

How to close or kill an IE window with JavaScript.

Posted on 2013-01-25
1
188 Views
Last Modified: 2013-01-25
When someone clicks a link on one of my pages I create a pop-up window with javascript called "theWindow". Sometimes this window will get lost behind other windows so if someone clicks another link on the page it will load that link in the other pop-up window but it will appear to them that nothing is happening since the original window is still up but behind the other windows. I'd like to put an onclick event before the current one to kill any pop-up windows. Could someone assist?
0
Comment
Question by:earwig75
1 Comment
 
LVL 18

Accepted Solution

by:
nap0leon earned 500 total points
ID: 38819545
When you create the popup window, open it as an [object] that you can then reference in your "close me" function.
<script>
function OpenIt() {
	childWindow=window.open('popup');
}

function closeIt(){
	if (typeof childWindow != 'undefined') {
		childWindow.close();
	}
}

</script>
<a href="javascript:void(0);" onclick="OpenIt()">Open It</a><br/>
<a href="javascript:void(0);" onclick="closeIt()">Close It</a>

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question