• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Referring to a child window?

 
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an HTML page where user needs to login to view the page.

Then there's a link in the HTML page.
When user clicks the link, it opens a pop-up box.

How do I close this pop-up box when I sign out from the parent page?
Is there anyway to do this?
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The window.open function returns a handle to the newly created window.
You can assign that to a var and use that to refer to it.
 
Susan Smith
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you. It's working great.
 
Susan Smith
Ranch Hand
Posts: 224
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually, there's one problem.

I have external javascript called myjavascript.js




Then when i logout in the parent page, let's call it A.html, I do this below:



The code works fine in this case:
1.) Open A.html
2.) Click a link in A.html to open "mywindow"
3.) Sign out, then I see that 'mywindow' is also closed when I click "Sign out"

But not in this case:
1.) Open A.html
2.) Click a link in A.html to open "mywindow"
3.) Reload A.html
4.) Sign out, then I see that "mywindow" is not closed when I click "Sign out"

I think it's because in step. #3, the mywindow variable is initialized to "undefined" again. How do I prevent this from happening?
 
Sheriff
Posts: 67634
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't. Once the parent window is unloaded, any reference to the child is lost.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Once the page is refresh, navigated away form, posted back, etc all of the JavaScript variables are killed. There is no way to keep this from happening so the child window will be orphaned.

You can close the window with onbeforeunload or onunload and reopen it when the page is loaded again. Other than that, you are out of luck.

Eric
 
The only cure for that is hours of television radiation. And this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic