How to close a pop-up window which was opened by java script.
-
Hi ppl This is my first question......i think i will get my answer sonn....... Right now im working in a web application.....In which most of the pages are popups..Im opening a popup window from a Main parent popup using JavaScript windows.open(),which is actually a search page,used to search for a particular user of the system.on selecting a particular user the control returns to the main popupwindow....... The problem is when the user logs off....i need to close all the popups opened by the user..for that i used..... window.top.close()...to close main popup window ,which has the logout button. winsearch.close()..... to close the search popup...but this child window is not getting closed.... Im using Asp+C# for my application........Help needed ASAP..... i think description is elborate to understand the problem....... one of my friend told me thet after several postbacks by asp.....the reference "winsearch" used by java script got disappeared from cache memory....thats y it is not getting closed.. is that true??!!!.....
-
Hi ppl This is my first question......i think i will get my answer sonn....... Right now im working in a web application.....In which most of the pages are popups..Im opening a popup window from a Main parent popup using JavaScript windows.open(),which is actually a search page,used to search for a particular user of the system.on selecting a particular user the control returns to the main popupwindow....... The problem is when the user logs off....i need to close all the popups opened by the user..for that i used..... window.top.close()...to close main popup window ,which has the logout button. winsearch.close()..... to close the search popup...but this child window is not getting closed.... Im using Asp+C# for my application........Help needed ASAP..... i think description is elborate to understand the problem....... one of my friend told me thet after several postbacks by asp.....the reference "winsearch" used by java script got disappeared from cache memory....thats y it is not getting closed.. is that true??!!!.....
Welcome to CodeProject.
rajmahen wrote:
for that i used..... window.top.close()...to close main popup window ,which has the logout button.
AFAIK,
window.top
is not part of any standard. It looks like it works only with Mozilla. Declare a local variable and assign the return value ofwindow.open
to it(assume variable name issearchWindow
). Hook a JS event handler in the logout button click. Inside this handler, checksearchWindow
and if it is assigned, callclose
on it. :)Navaneeth How to use google | Ask smart questions
-
Hi ppl This is my first question......i think i will get my answer sonn....... Right now im working in a web application.....In which most of the pages are popups..Im opening a popup window from a Main parent popup using JavaScript windows.open(),which is actually a search page,used to search for a particular user of the system.on selecting a particular user the control returns to the main popupwindow....... The problem is when the user logs off....i need to close all the popups opened by the user..for that i used..... window.top.close()...to close main popup window ,which has the logout button. winsearch.close()..... to close the search popup...but this child window is not getting closed.... Im using Asp+C# for my application........Help needed ASAP..... i think description is elborate to understand the problem....... one of my friend told me thet after several postbacks by asp.....the reference "winsearch" used by java script got disappeared from cache memory....thats y it is not getting closed.. is that true??!!!.....
1. You can try to use window.showModalDialog instead of window.open. Though this is not a W3C standard, Firefox supports it now. 2. You can try Observer design pattern, each popup windows opens, add itself handle to the close event.
-
Welcome to CodeProject.
rajmahen wrote:
for that i used..... window.top.close()...to close main popup window ,which has the logout button.
AFAIK,
window.top
is not part of any standard. It looks like it works only with Mozilla. Declare a local variable and assign the return value ofwindow.open
to it(assume variable name issearchWindow
). Hook a JS event handler in the logout button click. Inside this handler, checksearchWindow
and if it is assigned, callclose
on it. :)Navaneeth How to use google | Ask smart questions
Thank u navaneeth...............i implemented in tit is not working.....it closes the top window but not the child window.... This is my code snippet: //Function to open the search user popup screen. Only one search window allowed to display var winSearchUser; function openSearchUser() { if(winSearchUser == null || winSearchUser.closed) { winSearchUser = window.open('SearchUser.aspx','SearchUser','height=600, width=850,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no '); } winSearchUser.moveTo(10,10); winSearchUser.focus(); return false; } //Function to close all the child popup windows of this window function closeAllPopups() { //Close the main window window.top.close(); //Close search user popup if ( winSearchUser != null ) { winSearchUser.close() ; winSearchUser = null ; } } i attached the above close script in the client script manager of the main windows asp.