Click to See Complete Forum and Search --> : Difference in Script for NS and IE


bharadwajrv
October 3rd, 2002, 02:56 AM
hi,
1. i have a script for diplay drop down menus..using <div> method for IE 5.0.. can the same this be used for Netscape also.

or where all we need to ensure that chnage in code for IE and NS.


2. How to detmine the from which browser the page is being view..either from IE or NS..

any idea..
thanks in adv.

Venu

Waldo2k2
October 3rd, 2002, 07:12 AM
first of all, ie and ns are html 4 compliant, divs are part of html 4 (i think they go back farther than that though).
Second, post your code so we can show you how to cross-browser script.
Third,

var browserName=navigator.userAgent;
var browserVersion=parseInt(navigator.appVersion);
function whatBrowser()
{
if (browserName=="Internet Explorer") //it may be MSIE, can't remember
{
window.location.url="iepage.htm";
}
else
{
window.location.url="nspage.htm";
}
}

<body onload="whatBrowser()">

websmith99
October 3rd, 2002, 06:44 PM
Here's a good way to do browser detection:

if (document.all) {
// IE4, IE5, IE6 specific code
} else if (document.layers) {
// NN4 specific code
} else if (document.getElementById) {
// NN6 specific code
}


Because both IE6 & NN6 support document.getElementById, you have to be sure to first check for document.all. Otherwise if you check for document.getElementById first, then IE6 will try to do your NN6 specific code.

I haven't experimented much yet with NN7, but I assume the DOM is compatible with NN6.

bharadwajrv
October 8th, 2002, 04:13 AM
Hi,
here is my code to show the drop down menu.. it is working fine in IE 5.0.... but it is not working in Opera.. i have not checked in Netscape..

pl. find the my code in the attachmnet...

pl. can u give input regrading this...

thanks in adv..

Venu

Waldo2k2
October 8th, 2002, 05:40 PM
first of all, in your onmouse whatever statements where you change background colors, the netscape extension to css uses the background-color as opposed to backgroundColor, so, include the change for background-color as well in that event.
Second, use if statements in the .js file

if (document.all)
{
...
}
else
if (document.layers)
{
mnuObj = document.layers[popmenu];
...
}
else
if (document.GetElementById)
{
mnuObj=document.GetElementById(popmenu);
...
}


i think that about covers it