Solved

How to close or kill an IE window with JavaScript.

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now