Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to close or kill an IE window with JavaScript.

Posted on 2013-01-25
1
Medium Priority
?
195 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 2000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

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…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…
Suggested Courses

926 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