Forum Moderators: open
I would appreciate any help on this problem. I have a JavaScript that opens a window and initializes the value of a textarea element. It works in IE6 but does not work in NS 6.1. The script is a text book variety but I must be doing something wrong or not compatible with NS, because when I open the page in NS the new window opens without any value in the textarea element. It seems that this statement:
<<<<<<< snip >>>>>>>>
helpWindow.document.inputForm.exhibit.value = field.value;
<<<<< snip >>>>>>>
doesn't work. The following is more of the script. What am I doing wrong can someone please help?
var helpWindow = 0;
function openWindow(url,title, field )
{
if(helpWindow){
…
}else{
helpWindow = window.open(url, 'title', 'scrollbars,resizable,width=350,height=300');
}
helpWindow.document.inputForm.exhibit.value = field.value;
helpWindow.focus();
alert ("Done ");
}
thanks in advance
Give the element an ID, and use something like this:
if(document.getElementById) {
// For newer browsers...
document.getElementById('the_ID').value = "blah";
}
else if (document.all) {
// For older IE...
document.all['the_ID'].value = "blah";
}
<input type="hidden" name=exhibit value='#include ....'>
The value is large piece of text which I'm trying to transfer to the textarea element on a second window so that the user can edit it.
The following is the call that is supposed to open the second window and initialize it.
<input type=radio name=exh_type value=”EMBEDDED “ checked onclick='JavaScript: openWindow("html/getExhibit.htm", "Supplemental Information",input.exhibit);'>
This is really puzzling to me but I'll keep probing it and crossing my fingers that something will fix it.
Thanks
<HTML>
<script>
var helpWindow = 0;
var isWindowLoaded = 0;
var string ="";
function openWindow(url,title, field)
{
if(helpWindow){
x=0;
}else{
helpWindow = window.open(url, 'title', 'scrollbars,resizable,width=350,height=300');
}
string=field.value +"";
helpWindow.focus();
isWindowLoaded = setTimeout('checkWindowLoaded()', 250);
}
function checkWindowLoaded()
{
isWindowLoaded=clearInterval();
if (typeof(helpWindow.document.inputForm)!="undefined")
{
helpWindow.document.inputForm.exhibit.value = string;
}
else
{
isWindowLoaded = setTimeout('checkWindowLoaded()', 250);
}
}
</script>
<FORM name=input>
<input type="hidden" name=exhibit value='TEST TEXT'>
<input type=radio name=exh_type value=”EMBEDDED“ checked onclick='JavaScript: openWindow("open.htm", "Supplemental Information",input.exhibit);'>
</form>
</HTML>
After getting a working solution, I think it best not to use it. I would post the contents of the element to the new window and use Perl, instead of JavaScript, to parse the contents.
-Mark
After reading your suggestions and especially Mark’s remark at the end, I have to conclude that there is no way to safely initialize a form element through JavaScript that will work for NN. I’m going to have to do it through server side programming.
Thanks again for all your help.