Forum Moderators: open

Message Too Old, No Replies

Referencing another window using the DOM

Is it possible?

         

ronin

4:29 pm on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm modifying a 'recommend this page' form which pops up in a separate small window, when users click on the relevant button.

The same form pops up for every page - so I wouldn't normally know which pages are being recommended.

To compensate for this I have a field in the form which says: 'Page to Recommend:' and the field contains the homepage of the site as a default.

Evidently this solution isn't nearly user-friendly enough, because users never, ever edit the field. And so the page which gets recommended is always the homepage.

So I am looking to auto-fill that field with the name of the page that the user would like to recommend.

I've got as far as using javascript to autofill the field... but the url is always the url of the popup window, whether I use


parent.location.href

as a reference or something else.

Is there a reference I can use for the window which spawned the javascipt popUp?

Many thanks in advance.

AWildman

4:41 pm on Oct 14, 2003 (gmt 0)

10+ Year Member



Try window.opener.location.href

drbrain

4:43 pm on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



window.opener refers to the window that opened you, window.open returns a reference to the child window you've opened, for bidirectional communication.

ronin

8:51 pm on Oct 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank you, both of you, it works perfectly.
You people on this forum rock my world.