Wrox Programmer Forums
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript 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
 
Old November 18th, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opener

Hi,

I have 2 frames (top,bottom).. The bottom frame executes the OpenWin() function which opens a new window... Now when I try to close it using 'document.bottom.opener.close();' it doesn't work. The error that it gives me is 'document.bottom.opener' is null or not an object. Am I misusing opener? Also, before someone mentions it, I can't add a variable for the window.open (ie newwin = window.open)...

function OpenWin()
{
   window.open("","HSEUsage","scrollbars=yes,resizabl e=yes,menubar=no,toolbar=no");
}

 
Old November 18th, 2005, 11:03 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

opener refers to the document that opened the window, not the window that was opened.

So you want something like this:

Code:
var $HSEUsage;

function OpenWin()
{
    $HSEUsage = window.open("","HSEUsage","scrollbars=yes,resizable=yes,menubar=no,toolbar=no");
}

function CloseWin()
{
    $HSEUsage.close();
}
HTH!

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old November 18th, 2005, 12:31 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

As I said, I can't declare a variable for the new window... and since I was off base with the opener function, how does one read what's on thew new window??

 
Old November 18th, 2005, 12:48 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> As I said, I can't declare a variable for the new window

Er? You haven't presented a case for why you can't declare a variable. How about enlightening us a little more about your thought process and what you expect to achieve.

You either declare a variable for the window, or close the window from within it.

> how does one read what's on thew new window

Via the variable you assign the object resulting from the window.open handler for the new window, there's no other method AFAIK to access a subordinate window.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old November 18th, 2005, 02:01 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The reason that I can't declare a variable for the window is that I don't control the content of that page. I'm loading a page through an iframe, once this page is loaded I simulate the click on a button, sadly instead of just changing the page to the new content, they open a new window. Now what I'm trying to do, is get data from the popup, then close it when done.

 
Old November 18th, 2005, 02:24 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Then it appears you're trying to do cross-domain scripting. It can't be done.

Imagine a phishing website that loads a bank website in a frame, then in the evil frameset, a javascript records every keystroke and sends them back to evil webmaster's server via XMLHttpRequest. Whaalah, now some doophus has some poor sap's bank username and password.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old November 20th, 2005, 02:11 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Well, that's not my intentions whatsoever... But it's nice to know that it can't be done... Thank you.

 
Old November 21st, 2005, 11:27 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> Well, that's not my intentions whatsoever... But it's nice to know that it can't be done... Thank you.

I wasn't implying that it was, just trying to convey the reason why it isn't possible. ;)

You'd have better luck manipulating content from other sources on the server-side, BTW, before it even gets to the client.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design





Similar Threads
Thread Thread Starter Forum Replies Last Post
window.opener for mozilla jun99 Javascript 3 September 1st, 2009 08:57 AM
opener.document davidph Javascript 2 May 26th, 2007 01:36 AM
Problem accessing the window.opener.opener maryuob Javascript 3 January 18th, 2006 05:25 AM
window.opener help fs22 Javascript How-To 6 May 9th, 2004 10:50 PM
Access the opener? richard.york Javascript 1 January 4th, 2004 09:36 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.