Monday, May 13, 2024
167
rated 0 times [  173] [ 6]  / answers: 1 / hits: 17611  / 13 Years ago, tue, october 4, 2011, 12:00:00

I am trying to use the following JavaScript to check if a popup page is still open.



The parent page (calling page to open popup) is open but this code continues to fail. I am calling it from an aspx popup page that has a masterpage inside another masterpage. So the click event that eventually calls this script is an Edit Link in a Gridview in a content Placeholder which is in the upper most master page content Placeholder, not sure if that has anything to do with it. The script fires but it does not see the parent page as open and not closed.



if (window.opener != null && !window.opener.closed) { 
alert(window.opener);
var val = window.opener.parentFunc(a);
alert(a);
}


This is an IE only problem, Firefox can identify the window.opener page. Tried multiple versions of IE all had issues, Firefox and Opera work though.



I actually used this alert statement....



alert(window.opener);


In IE returns Undefined.



In Firefox returned ObjectWindow.


More From » internet-explorer

 Answers
11

I got this to work by sending the script from VB.net like this....



Dim BrowserSettings As String = status=no,toolbar=no, scrollbars =yes,menubar=no,location=no,resizable=no, & titlebar=no, addressbar=no, width=650 ,height=800
Dim URL As String = testNewPage.aspx
Dim scriptText1 As String = (<script>javascript: var w = window.open(' & URL & ','_blank',' & BrowserSettings & '); </script>)
ScriptManager.RegisterStartupScript(Me, GetType(Page), ClientScript1, scriptText1, False)here


This isn't exactly what I wanted, but it seems to be working except now the popup page is not on top. Need to figure that part out.



I have been trying to apply focus, doesn't seem to work.
Also, tried a modaless popup, that works but I lose the reference to the open window then.


[#89803] Sunday, October 2, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mackennamelissac

Total Points: 110
Total Questions: 118
Total Answers: 103

Location: Sweden
Member since Sun, Jan 16, 2022
2 Years ago
;