 |
| Javascript How-To Ask your "How do I do this with Javascript?" questions here. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 7th, 2004, 02:05 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
window.opener help
I have a browser window that has the following code in a link...
javascript:openWindow('Lessons/ap_les/ap_index.htm');
The openWindow function is as follows...
function openWindow(url) {
popupWin = window.open(url, 'lesson', 'menubar=no,toolbar=no,location=no,directories=no, status=no,scrollbars=yes,resizable=no,dependent,wi dth=780,height=510,left=5,top=25')
}
What I am trying to do is to create a hyperlink on the opend window that once clicked will change the document being displayed in the frame of the opener window. Has anyone ever done this?
I tried the following code...
<script language="JavaScript">
function quizClick ()
{
var winOpen = "quizzes/ap_quiz/ap_quiz.htm";
window.opener.document.location = winOpen
return;
}
document.write("<a href=# onclick = 'quizClick();'>Take a Quiz</a><p>");
</script>
But I get the error that windo.opener.document is null or not an object.
Any thoughts?
Clay Hess
__________________
Clay Hess
|
|

May 7th, 2004, 02:44 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Clay,
In what browser do you get the error? I tried your code and I was able to get it to work with one little fix. Instead of setting the location of the opener, you should set location.href like this:
Code:
window.opener.document.location.href = winOpen;
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Grand Black Citizen by Urban Dance Squad (Track 10 from the album: Life 'n Perspectives of a Genuine Crossover) What's This?
|
|

May 7th, 2004, 02:52 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar,
Thanks for your help. I am using IE6 presently. I cannot get it to work and I think it is because in my opener I am using frames. How do I use the opener with a framed site?
Quote:
quote:Originally posted by Imar
Hi Clay,
In what browser do you get the error? I tried your code and I was able to get it to work with one little fix. Instead of setting the location of the opener, you should set location.href like this:
Code:
window.opener.document.location.href = winOpen;
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Grand Black Citizen by Urban Dance Squad (Track 10 from the album: Life 'n Perspectives of a Genuine Crossover) What's This?
|
Clay Hess
|
|

May 7th, 2004, 03:00 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Try window.opener.top.location.href or window.opener.parent.location.href if you want to replace the frameset and you opened the window from a certain frame.
Snib
<><
|
|

May 7th, 2004, 06:05 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What is I want it to simply replace the frame it came from and not the entire frameset? Would it be window.opener.parent.content.location.href?
Quote:
quote:Originally posted by Snib
Try window.opener.top.location.href or window.opener.parent.location.href if you want to replace the frameset and you opened the window from a certain frame.
Snib
<><
|
Clay Hess
|
|

May 7th, 2004, 06:15 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
I think what you said will work. That or window.opener.parent.frames['framename'].location.href='wherever.html';
Try it and let us know if it was what you were looking for.
HTH,
Snib
<><
|
|

May 9th, 2004, 10:50 PM
|
|
Friend of Wrox
|
|
Join Date: Apr 2004
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks everyone for your help. I realized what the problem was. I was doing my code right for a "normal" situation. The reason it was not working is because the program that our developers wrote that contains the link that opens the separate window, opens it up in its own process. So therefore I cannot access the opener property...unless anyone knows how to use javascript to access other processes occurring? Thanks for your help.
Quote:
quote:Originally posted by Snib
I think what you said will work. That or window.opener.parent.frames['framename'].location.href='wherever.html';
Try it and let us know if it was what you were looking for.
HTH,
Snib
<><
|
Clay Hess
|
|
 |