View Full Version : What browsers is Javascript compatible with?

09-23-2005, 01:18 AM
Some people can't seem to see my Javascript coding, even from IE- I was wondering just what browsers do work with it and which ones don't. Is there some way to make the coding work with other browsers too? Thanks. :)

09-23-2005, 02:00 AM
Some methods don't work with some browsers.


09-23-2005, 02:06 AM
Error 795: Not enough info.

JavaScript in some form is supported by virtually every browser going back to the days of Netscape 2.0. If browsers didn't have it, they were left in the dust behind the large and growing Netscape Navigator, and the new and upcoming Internet Explorer. Netscape created JavaScript, designed it, and lead the development of it till it dropped dead in the hands of AOL.

Pretty much every browser supports JavaScript. But of course, JavaScript is only half of it. Netscape and Microsoft went their separate ways with generation 4 browsers. Netscape produced their way of scripting web pages, Microsoft another way, but they both used JavaScript as the language. This is the era of "Page best viewed with Netscape/Internet Explorer" messages. And corny effects. And 150KiB pages catering to both browsers. Eventually, both companies realised a standard had to be created and the W3C DOM was born. Internet Explorer 5 was first out supporting it, and Netscape had huge problems with crashes and security. They didn't quite get a new version out of the door. They decided to rewrite from scratch, which probably was the worst mistake out of that company. Eventually a very good browser was to come out of it, Mozilla, but by that time Internet Explorer owned the market.

Microsoft released a version 6 that was moderately improved upon 5.0 and 5.5. Netscape released their browser while it was still in pre-alpha and of course, they got a reputation of buggyness and slowness that just piled on the instability of their older browser.

During this time, the DOM standard had evolved way beyond what Internet Explorer supported. Opera and Mozilla started taking market share. Apple joined the race with Safari, and today we see four "big" browsers out there: Internet Explorer, Mozilla, Safari and Opera. The last three are pretty similar in supported features, with Mozilla currently being the most complete and stable one. Internet Explorer has not gotten any significant update when it comes to scripting in years.

In other words, what I'm saying here is that every browser has done things somewhat differently, but also supported standards more and more, added new stuff that is beginning to get standardised, etc. All using the same language, JavaScript. So, just because JavaScript is supported doesn't mean you aren't using features that doesn't exist in other browsers, or that might work differently. Add to that browser settings, firewalls, proxies, antispam and antivirus programs ("security" programs) that might prevent some scripts from working.

09-23-2005, 06:53 AM
Javascript can be broken up into three pieces

- ECMAscript which is the core language supported by all browsers that support the appropriate level of Javascript

- the Document object model (DOM) which provides access to the current web page most of which is supported by version 6+ browsers (and some even by version 5 browsers)

- the browser object model which provides info about the browser. With special functions that test which of three or four different methods is supported you can write code that is effectively browser independent.

Recent versions of most web browsers support Javascript 1.5 as well as a big part of the DOM. The DOM has now been fully defined so the next generation of browsers ought to support it fully as it is no longer a moving target.

The one exception is Internet Explorer which does not support any version of Javascript at all but which instead uses its own scripting language called JScript. Javascript is close enough to JScript so that code written in Javascript can be modified slightly to run on Internet Explorer. The same is not true the other way around as JScript has many constructs that Javascript does not.

09-23-2005, 03:22 PM
The one exception is Internet Explorer which does not support any version of Javascript at all but which instead uses its own scripting language called JScript. Javascript is close enough to JScript so that code written in Javascript can be modified slightly to run on Internet Explorer. The same is not true the other way around as JScript has many constructs that Javascript does not.Not really correct as such. ECMAScript is the only standardised version of JavaScript, and that's supported by Microsoft's JScript as well as by any other browser's scripting engine. There is a set of behaviors that are not in ECMAScript that you will find are the same in all browser scripting engines as well, but these parts are also supported by JScript.

It's true that JScript adds some things that will not work in any other JavaScript scripting engine, but so does both Mozilla's engines too, as well as all other engines. There are simply different needs from the different browsers to support their underlying technology. That doesn't make them any less JavaScript compatible. They all fully support JavaScript as such. They only differ in what they support in addition to the core langauge.

09-24-2005, 12:12 AM
That's what I said. Both Javascript and JScript share ECMAScript as their common functionality as well as some parts of the DOM. Apart from sharing common component parts like this they are two different languages and to get your code to work on both Javascript and JScript you need to use feature sensing to determine whether the browser supports the Javascript way or the JScript way of processing.

Javascript and JScript are two DIFFERENT languages that are both based on ECMAScript and the DOM. They are not the only languages so based either eg. ActionScript and ScriptEase are also derived from ECMAScript and the DOM.

09-24-2005, 05:27 AM
Well, what I'm saying is that you twist it wrong: They are both ECMAScript. They are the same language. Like different C compilers have their special behaviors and quirks, so does the different JavaScript engines, but they are still not different langauges. Just one language. And of course you have to add the browser differences, those are not at all related to the actual language.

09-25-2005, 01:23 AM
Javascript = ECMAScript + part(DOM) + unique(BOM)
JScript = ECMAScript + smallpart(DOM) + different(BOM)

Both are ECMAScript but the rest of the two languages are different. There is just enough overlap that simple scripts work on all browsers. More complex scripts either work on browsers that support Javascript or they work on IE (as JScript) but don't work on both.

For example:

document.getElementById("myLayer").firstChild.data = "This is MY layer.";

This is valid Javascript for updating the content of the page element having the id="myLayer". It is not valid JScript as JScript doesn't support firstChild.


This is valid JScript since showModalDialog is a valid method within JScript. It is not valid Javascript.

Javascript and JScript have a lot of common code which allows code to be written that will be correctly processed regardless of which of the two languages that the browser understands. Both of these languages (as well as several other different languages) are extensions of ECMAScript that include a lot of non-ECMAScript processing (in particular the Document Object Model and Browser specific addons).

Javascript != JScript but ECMAScript is a subset of both.
And the final point that proves that they are all different things is that the latest version of each has a different version number.

ECMAScript third edition
Javascript 1.5
JScript 5.0

09-25-2005, 03:38 AM
No. The host environment has nothing to do with JavaScript. That includes browser, document, appliction and any other object model available from the host. JavaScript is still JavaScript when used in any other environment than the browser. You can find JavaScript as server language, as shell scripting language and as macro language. The window object and all it's enumerable children that can be found in browsers are all added on top of the language, they are not part of the language. ECMAScript is the standardised version of JavaScript.

Let me hijack your example to show you just why I say this:

You say
"dialogWidth:255px;dialogHeight:250px");is valid JScript but not JavaScript, right?

Okay, say I have a proxy adding this script before any other script on my pages:

function showModalDialog(a,b,c){
alert('This page just tried to display a modal dialogue box. The box would have contained the page "'+a+'", would have had the name "'+b+'" and would have had the properties "'+c+'"');
Then the example you showed would indeed work in other browsers than iew. It would not work in the same way, but it would work. So, have I suddenly now created another language, one that has the exact same syntax and behavior, but has one added function? But as soon as I turn the proxy off, the same browser, with the same scripting engine, suddenly revert back to it's old language?

I'm pretty sure I'd get a very strong backup on this when I say: No. It's not another language. I also bet most would agree with me that something that doesn't change the language mechanics, grammar or syntax isn't a change in language. It's just a change in libraries. And from that reduction, you see that the only host environment parts that would possibly build another language are those affecting the libraries that are already in ECMAScript: the libraries for language native types; the libraries that are vital for behavior, error handling, scope handling, context handling, inheritance and delegation, syntax and grammar.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum