Page 1 of 1
href not working in Netscape
Posted: Thu Oct 03, 2002 2:18 am
by noguru
Hi,
This is working in Internet Explorer, but not in Netscape:
Code: Select all
function doNav(){
alert('working!');
location.href="options.php?id="+document.all.facultyid.value;
}
where facultyid is the name of an input field with type=text. I call the function on the click of a hyperlink. The alert is working, but not the href.
Any idea how I can change this to work in both IE and Netscape?
Thanks
Posted: Thu Oct 03, 2002 4:02 am
by mikeq
It has to do with the differences in the DOM (Document Object Model), document.all does not exist in Netscape.
You may need to do something like
document.forms['myformname'].facultyid.value;
here is a sample of some code I have used in the past
var isIE4 = (document.all ? true : false);
var isNS4 = (document.layers ? true : false);
if (isNS4)
{
window.onLoad = function()
{
document.layers['apphead'].document.forms['myform'].searchname.focus();
}
}
if (isIE4)
{
window.onload = function ()
{
document.forms['myform'].searchname.focus();
}
}
This detects the browser type then references the objects in different ways, in addition the form was within a layer so added complication there
document.layers['layername'].document.forms['formname'].formitemname.focus();
In this case a form is on a document within a layer on the main document.
Hope this helps, you should also look up DOM in google and do a bit of reading.
Posted: Thu Oct 03, 2002 4:54 am
by noguru
thanx mike, i'll try that.