Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HTML Close window

Posted on 2014-01-09
20
Medium Priority
?
334 Views
Last Modified: 2014-01-10
Hi,

Basic one but cannot get my head on it.

I have a main page that opens other windows. I would like to help the login page close all other windows that not the parent.

Thanks
0
Comment
Question by:Gareth_Pointon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 9
20 Comments
 
LVL 34

Expert Comment

by:Big Monty
ID: 39769274
you need to keep track of all of your windows that you open, then you'll be able to close the ones you want. There's no way to automatically close all child windows without keeping track of them.

Here's a good tutorial that keeps track of the child windows, then a function to close them.

http://www.codelodge.net/2012/11/closing-all-child-windows-using.html
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39769310
the child ask the parent to close

opener.closeAllButNotMe("myName");

window.closeAllButNotMe = function( dontCloseMeName ) {
    for(windowName in window.windows) {
         if( windowName != dontCloseMeName ) {
                 var windowObj = window.windows[ windowName ];
                 windowObj.close();
         }
    }
}

Open in new window


when you open a window, you need to save its name and instance
you save this in a global var, in my example it's windows

var name = "login";
window.windows[name] = window.open(url, name, params);

// somewhere else
var name = "otherName";
windows[name] = window.open(url, name, params);

Open in new window

0
 

Author Comment

by:Gareth_Pointon
ID: 39770614
Hi,

Regarding the following script:


// somewhere else
var name = "otherName";
windows[name] = window.open(url, name, params);

If this for the subsequent windows opened from the child?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 82

Expert Comment

by:leakim971
ID: 39770667
if the child open itself window, you need to do the same thing but you talk about main page opening window
0
 

Author Comment

by:Gareth_Pointon
ID: 39770674
Hi,

A Little stuck as I cannot get this code to fire.
windowsclose.txt
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39770679
yes that can't work, you should try my code
0
 

Author Comment

by:Gareth_Pointon
ID: 39770744
How does your code fit together as tried yours and couldn't get that to work?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39770762
Test page : http://fiddle.jshell.net/63qDd/4/show/
http://jsfiddle.net/63qDd/4/

I added/created the global object windows : window.windows = {};
0
 

Author Comment

by:Gareth_Pointon
ID: 39770938
What about the Close?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39770955
which close? you've a close button on the two child windows to close their brother
0
 

Author Comment

by:Gareth_Pointon
ID: 39770963
I need to close the two windows that have been opened form the parent.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39770970
only parent or child can close the window
0
 

Author Comment

by:Gareth_Pointon
ID: 39770974
Yes and I'm trying to close the popups that are created from the parent on the parent.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39771003
- opener is useless in the parent window

work : http://jsfiddle.net/6wc4b/3/
0
 

Author Comment

by:Gareth_Pointon
ID: 39771025
I need to be able to close the child windows from the Parent opener.
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 800 total points
ID: 39771041
what don't you want from http://jsfiddle.net/6wc4b/3/ ?
0
 

Author Comment

by:Gareth_Pointon
ID: 39771081
Ar sorry I see..

Can it close them all?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39771085
At this point you should try to understand the code...
0
 

Author Comment

by:Gareth_Pointon
ID: 39771089
Yes I see just removing the value
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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)
Suggested Courses

618 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