window.opener with FireFox Issue

Discussion in 'Javascript' started by Asterix, Aug 8, 2008.

  1. Asterix

    Asterix Guest

    Hi Guys,

    I know this is probably an easy one, but I am having issues.
    Basically, I have a pop-up (child) that controls the parent window.
    Clicking on a link on the child window should redirect the parent.
    Unfortunately, I cannot get it to work with FireFox after selecting
    more than one option.

    Javascript code:
    function MM_openBrWindow(theURL,winName,features) {
    window.open(theURL,winName,features).focus();
    }

    function changeParent(theURL) {
    if (parentExists())
    {
    window.opener.location.href = theURL;
    }
    else
    {

    MM_openBrWindow(theURL,'myWindow','location=1,status=1,scrollbars=1,resizable=1,menubar=1,toolbar=1,width=600,height=500');
    }
    }

    function parentExists() {
    if (window.opener && window.opener.open && !window.opener.closed)
    return true;
    else return false;
    }

    This works for both Safari and IE 6 & 7, but not for FF 2. After
    clicking one link from the child window it redirects the parent
    correctly, but after selecting an additional link FF does not work.
    After installing FireBug I am getting the error: uncaught exception:
    Permission denied to get property Window.open.

    Function is called by:
    <a href="#" onclick="changeParent('<%#Eval("DetailPageURL") %>');
    return false;">Link 1</a>

    Any ideas or links for solutions would be appreciated.

    Thanks in advance,
    Sully
    Asterix, Aug 8, 2008
    #1
    1. Advertising

  2. Asterix

    GArlington Guest

    On Aug 8, 3:18 pm, Asterix <> wrote:
    > Hi Guys,
    >
    > I know this is probably an easy one, but I am having issues.
    > Basically, I have a pop-up (child) that controls the parent window.
    > Clicking on a link on the child window should redirect the parent.
    > Unfortunately, I cannot get it to work with FireFox after selecting
    > more than one option.
    >

    <snap>
    I tried your javascript code without ANY changes and
    parent body:
    <body>
    Parent<br/>
    <a href="__test11.html" target="_blank">Open child</a>
    </body>
    child body:
    <body>
    Child<br/>
    <a href="#" onclick="changeParent('__test1.html'); return
    false;">test1</a>
    <a href="#" onclick="changeParent('__test2.html'); return
    false;">test2</a>
    </body>
    and it works with NO problems even when I open multiple child
    windows...

    Your error message (if it was copied and pasted) implies that your
    code tries to use window.open property, NOT window.open() function.
    There is no trace of that in the code you provided...
    GArlington, Aug 8, 2008
    #2
    1. Advertising

  3. Asterix

    GArlington Guest

    On Aug 8, 3:18 pm, Asterix <> wrote:
    > Hi Guys,
    >

    <snap>
    > function changeParent(theURL) {

    You ONLY need to call your MM_openBrWindow() function here, because
    window.open() with named window is going to change the URL of the
    existing window, or will open the new one if it does NOT exist...
    <removed unneeded code>
    >
    > MM_openBrWindow(theURL,'myWindow','location=1,status=1,scrollbars=1,resizable=1,menubar=1,toolbar=1,width=600,height=500');

    </removed unneeded code>
    >
    > }

    <snap>
    GArlington, Aug 8, 2008
    #3
  4. Asterix wrote:
    > [...]
    > Javascript code:
    > function MM_openBrWindow(theURL,winName,features) {
    > window.open(theURL,winName,features).focus();
    > }


    This function is error-prone, window.open() does not need to return a
    reference to Window object, nor does the referred object needs to a
    have focus() method. And if the focus() call was omitted, the function
    would be completely superfluous.

    > function changeParent(theURL) {
    > if (parentExists())
    > {
    > window.opener.location.href = theURL;
    > }
    > else
    > {
    >
    > MM_openBrWindow(theURL,'myWindow','location=1,status=1,scrollbars=1,resizable=1,menubar=1,toolbar=1,width=600,height=500');
    > }
    > }
    >
    > function parentExists() {
    > if (window.opener && window.opener.open && !window.opener.closed)

    ^^^^^^^^^^^^^^^^^^
    > return true;
    > else return false;


    That is the equivalent of the equally pointless

    if (true)
    {
    return true;
    }
    else
    {
    return false;
    }

    Use

    return (...);

    instead. (Parentheses are optional).

    > }
    >
    > This works for both Safari and IE 6 & 7, but not for FF 2. After
    > clicking one link from the child window it redirects the parent
    > correctly, but after selecting an additional link FF does not work.
    > After installing FireBug I am getting the error: uncaught exception:
    > Permission denied to get property Window.open.


    Probably the URL of the first link uses a different URI scheme, a different
    port, or a different domain. In that case you are not allowed to access the
    `open' property of Window objects showing a document with such a URL, and it
    makes no sense testing for it here anyway.

    Do not use Dreamweaver's built-in script code snippets as they are known to
    be of poor quality. That said, do not use Dreamweaver without minimum clue
    because you think it can do it better than you -- it cannot.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
    Thomas 'PointedEars' Lahn, Aug 9, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andrew Bewley via DotNetMonster.com

    window to window communication (window.opener)

    Andrew Bewley via DotNetMonster.com, Feb 3, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,046
    Andrew Bewley via DotNetMonster.com
    Feb 3, 2005
  2. Urs Gubler
    Replies:
    0
    Views:
    152
    Urs Gubler
    Jul 2, 2003
  3. Stefan Sch?rmeli

    window.opener Issue with Firefox

    Stefan Sch?rmeli, Oct 28, 2004, in forum: Javascript
    Replies:
    2
    Views:
    148
    Grant Wagner
    Oct 28, 2004
  4. atlas
    Replies:
    1
    Views:
    134
    Martin Honnen
    Sep 7, 2005
  5. window.opener, form.opener?

    , Jul 14, 2006, in forum: Javascript
    Replies:
    5
    Views:
    283
Loading...

Share This Page