Solved

How to close or kill an IE window with JavaScript.

Posted on 2013-01-25
1
187 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

803 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