473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Closing pop up window on exit of main window in java script

Hi,

I open a window using window.open('win1') from a parent window, now this pop up window will have to be open until user uses the application.
On click of logoff or 'X' button on browser the pop up window needs to be closed on it self.

How can I do this?
I tried onunload(), window.parent but nothing working....basically
var myRef=winow.open(win1) will give a object refrence but this object will be active only for that page....how can i access this across the application.

Please let me know if any suggestions.

Regards,
Pramod
Oct 20 '08 #1
6 4594
Nepomuk
3,112 Expert 2GB
As this is a JavaScript Question instead of a Java Question, I'll move it to the JavaScript / Ajax Forum.

Check the Wikipedia Java article, if you don't know the difference between Java and JavaScript.

Greetings,
Nepomuk (Moderator)
Oct 21 '08 #2
acoder
16,027 Expert Mod 8TB
The pop-up window would have access to its parent through window.opener. You could periodically check that the reference is not null and then close automatically if it is.
Oct 21 '08 #3
The pop-up window would have access to its parent through window.opener. You could periodically check that the reference is not null and then close automatically if it is.
Could you please post some JS snippet for the same.
Oct 21 '08 #4
Expand|Select|Wrap|Line Numbers
  1. setInterval(chkParWin,2000)
  2.  
  3. function chkParWin(){
  4. if(!window.opener || (window.opener=='null')){
  5. window.close()
  6. }
  7. }
that should check every couple seconds to see if the window you opened your popup from is still there
Oct 21 '08 #5
Expand|Select|Wrap|Line Numbers
  1. setInterval(chkParWin,2000)
  2.  
  3. function chkParWin(){
  4. if(!window.opener || (window.opener=='null')){
  5. window.close()
  6. }
  7. }
that should check every couple seconds to see if the window you opened your popup from is still there

------------
Thanks for the reply, but this will prompt user a message,
I am still having the same issue. Let me detail more:-

in main JSP I call a pop up saying
myWin1= window.open("url", win1); (this would open (popup)another JSP)

now this JS function is present inside a JSP. The logoff button of application is in different JSP, onClick of this button I call a function closeWindows().

function closeWindows(){
//chk for wind closed or open then
myWin1.close();
}

but the variable myWin1 will have [object] only if I exit from the same page, when I navigate to different page this varibal will be null and cannot be closed.
Is there a way or possible to keep track of the JS object in different JSPs.
Oct 21 '08 #6
acoder
16,027 Expert Mod 8TB
No, there isn't which is why the suggestion is to close from the child window instead.
Oct 22 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: David Leon | last post by:
Is there any way to stop php.exe closing after it processes a PHP script? It doesn't seem to have the traditional options of an MS-DOS program. I am using Windows XP Pro and have associated .php...
6
by: Malcolm Webb | last post by:
I have experimented with the routine to prevent access from closing using the module authored by Dev Ashish to be found at "The Access web" site. Whilst this seems to work, it is not exactly what...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
5
by: Wei | last post by:
I need the current window stay on focus. The user will have to click on exit button to exit the window. How can I do this in asp.net in C#? Thank you
14
by: fiziwig | last post by:
I was looking for a way to have a popup window appear when someone left my page, but not have it appear when they hit the refresh or back buttons on the browser. Since using onUnload="..." in the...
1
by: cnsabar | last post by:
Hi I am having a problem in closing a menu window using TK module dynamically. I use the following program. use Tk; $mw = MainWindow->new; $mw->geometry("1024x768");
5
by: sbettadpur | last post by:
Hi, Please help me, Here i have a problem When i am trying to close the main browser i need to popup a confirmation window actually i had a code that is working on IE browser with some...
1
by: houh | last post by:
I have a java app that generates openoffice docs. When I run the java app in a shell script, as: export JAVA_HOME=/opt/corp/projects/metrics/Java/jdk1.5.0_07/bin/java export...
3
by: globalrev | last post by:
im doing this : http://www.learningpython.com/2006/03/12/creating-a-game-in-python-using-pygame-part-one/ and when closing the program the window stays up and doesnt respond. i tried adding...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.