window.opener with FireFox Issue

A

Asterix

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
 
G

GArlington

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

GArlington

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...
MM_openBrWindow(theURL,'myWindow','location=1,status=1,scrollbars=1,resizable=1,menubar=1,toolbar=1,width=600,height=500');
<snap>
 
T

Thomas 'PointedEars' Lahn

Asterix said:
[...]
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top