Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 7th, 2004, 03:05 PM
Friend of Wrox
 
Join Date: Apr 2004
Location: Wausau, WI, USA.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old May 7th, 2004, 03:44 PM
Imar's Avatar
Wrox Author
Points: 67,581, Level: 100
Points: 67,581, Level: 100 Points: 67,581, Level: 100 Points: 67,581, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 16,269
Thanks: 66
Thanked 1,428 Times in 1,408 Posts
Default

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?
Reply With Quote
  #3 (permalink)  
Old May 7th, 2004, 03:52 PM
Friend of Wrox
 
Join Date: Apr 2004
Location: Wausau, WI, USA.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old May 7th, 2004, 04:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

<><
Reply With Quote
  #5 (permalink)  
Old May 7th, 2004, 07:05 PM
Friend of Wrox
 
Join Date: Apr 2004
Location: Wausau, WI, USA.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #6 (permalink)  
Old May 7th, 2004, 07:15 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: , , .
Posts: 1,285
Thanks: 0
Thanked 1 Time in 1 Post
Default

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

<><
Reply With Quote
  #7 (permalink)  
Old May 9th, 2004, 11:50 PM
Friend of Wrox
 
Join Date: Apr 2004
Location: Wausau, WI, USA.
Posts: 121
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener for mozilla jun99 Javascript 3 September 1st, 2009 09:57 AM
Resizing and moving new window through opener Gajender BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 July 22nd, 2008 09:40 AM
Problem accessing the window.opener.opener maryuob Javascript 3 January 18th, 2006 05:25 AM
window.opener problems crmpicco Javascript How-To 2 September 30th, 2005 04:46 AM
window.opener.refresh matt.fields Javascript How-To 1 November 3rd, 2003 05:13 AM



All times are GMT -4. The time now is 09:44 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.