Forum Moderators: open

Message Too Old, No Replies

passing values

how to pass values in netscape

         

singularity

7:40 am on May 13, 2002 (gmt 0)

10+ Year Member



I'm trying to pass a value from a popup window to the page that opened it.

this is the code:

function insertVal(id,el)
{opener.document.form1.getelementbyid(el).value = '1'
self.close()
}

this works fine in IE, but fails in Netscape 4, with the error 'Directory listing denied'. ???

how can i make this work in n4?

joshie76

8:03 pm on May 13, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I haven't got NN4 at home so I can't check this though this *should* work (this is also the correct way to do it in IE etc...)

function insertVal(id,el)  
{
window.opener.document.form1.value = '1'
window.self.close()
}

josh

singularity

6:42 am on May 14, 2002 (gmt 0)

10+ Year Member



Possibly, but I need to set the value on a specific element (text type input box). The 'el' variable is the id of the element. That way, the function can be used generically.

Anyway, we decided to demand that our customers at least upgrade to Netscape 6, which is slightly more compatible with web standards. This has made the job somewhat easier since N6 recognize the getelementbyid keyword.

david752

3:36 pm on May 14, 2002 (gmt 0)

10+ Year Member



The function document.getElementById(id) is only supported by DOM-compliant browsers, which is only true of the latest browsers.

Perhaps this Javascript function might help (the code at the start detects the kind of major browser being used). [Sorry for the lack of indentation; Webmasterworld seems to remove it. If anyone knows how to include it, I'm interested.]

// Determine type of browser (OP (Opera), NS6, NN4, IE, or DOM)
// If multiple types, first one is it
var NN4=false; var IE=false; var DOM=false; var NS6=false; var OP=false;
if (navigator.userAgent.indexOf('Opera') >= 0) OP=true;
else if (navigator.userAgent.indexOf('Netscape6') >= 0) NS6=true;
else if (navigator.appName == 'Netscape' && navigator.appVersion.indexOf('4.') == 0) NN4=true;
else if (document.all) IE=true;
else
alert('Browser "' + navigator.userAgent + '" is not recognized.');
if (document.getElementById) DOM=true; //Unused

function GetElement(ArrName, Id)
{
if (ArrName == 'frames')
Where = 'window.' + ArrName;
else if (ArrName == 'forms')
Where = 'document';
else if (IE)
Where = 'document.all';
else if (OP)
return eval('document.getElementById("' + Id + '")');
else
Where = 'document.' + ArrName;

//alert('Where: ' + Where + ', Id: ' + Id);
if (eval(Where) == undefined)
alert(Where+' is undefined (std.js/GetElement)');
else
return eval(Where + '.' + Id);
//return eval(Where + "['" + Id + "']");
}