Perry Smith

Java Questions & Answers

Home / Java Q & A Archive Page 1 / Java Q & A Archive / Java Q & A Main Page


Walt Czyrnik
walter@midsouth.rr.com

Yahoo, I am in the process of beefing up my web site with some Java scripts. They are all still on my hard drive. I have been using IE4 to view them and they look great. Yesterday I thought that I would like to see if there were any appearance changes when viewed them with NN4. To my amazement 2 out of 3 did not work with NN4. But all 3 of them did with IE4. Being that 1 did work, told me that NN4's JAVA was enabled and in good working order. Does anyone have any ideas on a reason that could cause 2 out of 3 JAVA scripts NOT to run in NN4 but they work fine in IE4.

Thanks


Response
8-14-98

Why would two JavaScripts fail under Netscape 4 that worked under IE 4? The reasons are almost endless.

For example, the Document Object Model is different betwen the two. Each has unique objects that the other doesn't, and even within the objects they share, the methods and fields are often not the same.

It is often a good idea to have two different sets of Javascript for each browser (and more if different versions of the browsers have to be supported, since Javascript in each of the versions are not the same either). Here are two functions to tell the difference:

function isNetscape( )
{
return navigator.appName.indexOf("Netscape") > -1
}

function isExplorer( )
{
return navigator.appName.indexOf("Microsoft") > -1
}

As for figuring out what specifically is going wrong in Netscape, it is often a good idea to type the "javascript:" URL into the location box after running the problem page. Any errors should be displayed.

After programming in Javascript it is obvious why Java's mostly cross-platform behaviour is a good thing. I recommend that you check out "The JavaScript Bible" by Danny Goodman to see specifically what is supported by each browser.

Bruce Atherton
bruce@flair.law.ubc.ca


Home / Java Q & A Archive Page 1 / Java Q & A Archive / Java Q & A Main Page