By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,712 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,712 IT Pros & Developers. It's quick & easy.

window.opener with FireFox Issue

P: n/a
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,stat us=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
Aug 8 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Aug 8, 3:18 pm, Asterix <tollh...@gmail.comwrote:
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...
Aug 8 '08 #2

P: n/a
On Aug 8, 3:18 pm, Asterix <tollh...@gmail.comwrote:
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,stat us=1,scrollbars=1,resizable=1,menubar=1,toolbar=1, width=600,height=500');
</removed unneeded code>
>
}
<snap>
Aug 8 '08 #3

P: n/a
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,stat us=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, <f8*******************@news.demon.co.uk>
Aug 9 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.