Forum Moderators: open

Message Too Old, No Replies

Reference a form element in a seperate window

Don't know if it can be done

         

Greven

7:23 am on Mar 23, 2005 (gmt 0)

10+ Year Member



If this has already been covered and someone could point me in that direction, that would be great, as I couldn't find anything through the search function.

Basically, what I'm trying to acheive is to set a form element( a text area, to be precise) that exists in another window with a specific value. Both files are running locally, basically what I'm trying to acheive is to copy the value from a javascript calculator to a small notepad-type window, thats nothing but a text area. The window, opened through window.open, will always have the same title, but may not always be from the same parent, and that parent may not always be around. If need be, the parent can be present if it makes things easier.

I've tried things such as

 notepad.document.form1.textarea.value = "string";

and other variants of that but to no avail. Any help would be greatly appreciated, or if its even possible would be great as well.

SpaceFrog

8:24 am on Mar 23, 2005 (gmt 0)

10+ Year Member



I would try something like

var navigator.notepad= window.open(...

as you open the window...

you would then probably be able to retrieve elements with

navigator.notepad.document.form1.textarea.value

Greven

10:56 pm on Mar 23, 2005 (gmt 0)

10+ Year Member



Thanks for your quick reply.

If anyone else has such a circumstance, I was able get this to work through a couple bad bludgeons.

In my file that loads all of my smaller ones into the proper locations on my screen, I saved the return pointer from my "notepad" file to a variable. Then, to have this pointer as a refernce to one of the other children, after loading it and saving the return point from that to a seperate variable, I used


var notepad = window.open('notefile.html','notepad',
'width=410,height=216,status=no,scrollbars=no,resizable=no,toolbar=no,location=no,menubar=no,copyhistory=no,fullscreen=no,left=860,top=751,x=0,y=0');
//Open the quick links file
var q = window.open('quicklinks.html','QuickLinkWindow',
'width=1270,height=74,status=no,scrollbars=no,resizable=yes,toolbar=no,location=no,menubar=no,copyhistory=no,fullscreen=no,left=0,top=0,x=0,y=0');
q.opener = notepad;

With that, I can reference window.opener in my quicklinks file, and do the same thing to children of that file.

I also came across the problem of getting an "access denied" error. After a little hunting, I added this function to all the files that would need to reference each other, and it works great now.


function initializedomain()
{
document.domain = '';
}

SpaceFrog

7:57 am on Mar 24, 2005 (gmt 0)

10+ Year Member



navigator methode does work if you take var out ...

navigator.notepad= window.open(...

navigator.notepad.document.form1.textarea.value