supposing I have opened a new window with this statement:
newwin=window.open("newwin.php","newwindow");
Now I refresh the opener window and I want to know how to refer to the window I have opened?
![]() |
supposing I have opened a new window with this statement:
newwin=window.open("newwin.php","newwindow");
Now I refresh the opener window and I want to know how to refer to the window I have opened?
I don't think this is possible but I will do some testing tonight if I get time. When you call window.open, a window reference is stored in memory. Refreshing the page would clear this reference in the memory so that you are unable to reference the window. It might be possible from the child window though. I'll have to try it and see.
Out of curiousity - what are you trying to do?
Thanks a lot for yor caring and your nice question. Well, I'm making a website that has user login, logout feature. And user can work on multiple window, then I want whenever user sign on or out on one window, it automaticaly work the same on other windows visually so user don't have to refresh other windows to see that they are also logged in there. Right now I can only use self.opener property to do it if user do login, logout task on children window and I haven't found the way if use do it from parent window, so half of problem has not been solved.
By the way, I've been using ajax for those task.
Do you think that's a good idea?
If you get time, please have a look at my work here http://webmail.vimeco.com The default language is Vietnamese, feel free to click on the 'English' link on top-right of the page. You can find the user login session on the right, try login as user:doanxuanmanh; password:1234
And go to control panel after logging in
Please tell me if you have any idea. Thanks
By the way, the page may be slowly loaded, so thank you for your patient too :)
A better idea would be to use a session to track any information. When the user logins in, a session is created for that user. Then every new window you open could check this session for any information it needs. When the user logs off, the session is terminated.
This way, whatever window you have just needs to check if the user has a session assigned to them. If there is a session for the user then assume they are logged on.
I've no idea if Javascript has a session object but this could certainly be done using cookies anyway.
Sure, I've been using session for years and I don't mean to give it up now. Whenever user sign in or out on a window, that affect all windows in that session. But user can only see it when they refresh those windows. Here I just want user to relize that immediately and I also want to use this time to get more experience about window interacting
I see what you mean. I'll try and find some day to do some tinkering with some code myself and see what I can come up with.
I have the solution for it now, that may not a good solution but it works. I have added a function and set timeout for it so that it is always re-called for each 100 milisecond. This function will monitor its parent window status, once user sign in or out on parent window, my function will relize it and automatically do the task I want.
That's probably the easiest way. Bump up the delay though - 100 millisecs is a bit excessive.
All times are GMT -7. The time now is 04:06 AM. |