Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.opener is null in firefox

I have a page which opens the popup as

openWindow(top, 'prcsTypeSelectionPopup?event=prcsTypeSelection', 'lovWindow', {width:750, height:550}, true, 'dialog', pathCallBack);

and the popup has the following code

function returnSelect()
{
    window.document.forms[0].choice_processType.value ;
    window.opener.document.forms[0].pevent.value = 'getprocessName';
    window.opener.document.forms[0].processName.value='';
    for (var i=0; i < document.forms[0].elements.length; i++)
   {
   if (document.forms[0].elements[i].checked)
      {
      window.opener.document.forms[0].processName.value=document.forms[0].elements[i].value;
      break;
      }
   }
   if(window.opener.document.forms[0].processName.value=='')    {
        window.opener.document.forms[0].lovProcessType.value = '';
        window.opener.document.forms[0].pevent.value = '';
   }
    window.opener.document.forms[0].submit();
    closeConn();
}

function closeConn()
{
         self.close();
}

But when the page is loaded in firefox, am getting the error as window.opener is null at the 2nd line of returnselect() function

function returnSelect()
    {
        window.document.forms[0].choice_processType.value ;
        --> window.opener.document.forms[0].pevent.value = 'getprocessName';

Any idea how to overcome this

Thanks in advance...

like image 442
siva Avatar asked Mar 28 '12 07:03

siva


2 Answers

You open a window from another domain/subdomain. In this case you don't have access to parent window that opened the target window because security permissions don't allow that.

For example if you open a page of site2.com from a page of site1.com the target window has it's opener null.

If you open a page of site2.site.com from a page of site1.site.com it's also no access because these are two different sites.

But if you a page of site.com page from page of site.com or page of subdomain.site.com from page of site.com you have the access because security permissions allow that.

Note: maybe 'prcsTypeSelectionPopup?event=prcsTypeSelection' is incorrect. Change it to root correct path without domain, for example:

/prcsTypeSelectionPopup?event=prcsTypeSelection

like image 71
sergzach Avatar answered Nov 07 '22 11:11

sergzach


it works only for "parent.window.opener" and not for "window.opener"

Thanks Sergzach for your time

like image 23
siva Avatar answered Nov 07 '22 11:11

siva