最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - window.opener is null in firefox - Stack Overflow

programmeradmin3浏览0评论

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...

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...

Share Improve this question edited Mar 28, 2012 at 8:30 Adrien Schuler 2,4251 gold badge22 silver badges32 bronze badges asked Mar 28, 2012 at 7:06 sivasiva 1,1454 gold badges19 silver badges38 bronze badges 10
  • stackoverflow.com/questions/944066/firefox-window-opener-issue – sergzach Commented Mar 28, 2012 at 7:18
  • @sergzach: the page has no direct answer... can u pls help in my case – siva Commented Mar 28, 2012 at 7:37
  • Please let me know if my answer is not useful. It's an only idea, I do not know 100% decision. – sergzach Commented Mar 28, 2012 at 7:52
  • Try to use the standart window.open function instead of openWindow. Is there the same error? Or give the source code of openWindow. – sergzach Commented Mar 28, 2012 at 8:21
  • -> window.open( 'prcsTypeSelectionPopup?event=prcsTypeSelection', 'lovWindow' ); – sergzach Commented Mar 28, 2012 at 8:25
 |  Show 5 more comments

3 Answers 3

Reset to default 12

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, an example:

/prcsTypeSelectionPopup?event=prcsTypeSelection

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

Thanks Sergzach for your time

Try do disable the next Firefox extention: Tabbrowser Extensions (TBE).

It seems that there is the mentioned problem when using it .

发布评论

评论列表(0)

  1. 暂无评论