View Full Version : retrieve data from a window I did not open.
mattinflorida
03-08-2003, 09:19 PM
Is it possible to use javascript to retrieve form data from a window I did not open? And if so, how? The form I am trying to access uses hidden fields and is in a window where window.name has be specified. I have the form name and also the names of the fields I just can't seem to reference the window. When I attempt to use window.document.formname.fieldname.value i get 'window' is undefined even when I use the correct window.name value. I am rather new to javascript so I hope this isn't a stupid question. Your help is sincerely appreciated. Thanks!
cheesebagpipe
03-08-2003, 10:31 PM
You left out the most significant bit of information: who opened that window? If it contains a document (web page) from another server, forget about accessing it - the security model ('same origin policy') won't let you.
Just fyi: a window's name property is a string, and it's used by the system for TARGETing purposes, i.e., you can't script it, as it doesn't refer to a window object. If you know the name, however, you can get the object:
var handle = window.open('','window_name');
alert(handle.document.form_name.field_name.value);
mattinflorida
03-08-2003, 10:43 PM
Thanks for the information. Being a beginner I would be dead in the water without people like you.
And.. Yes the web page is opened by another server. It is generated by another program on our LAN that is written in java. So, I guess I am sol.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.