Javascript Function

Javascript Tutorials, Ajax , Validation, Calculator, DOM

« Not Quite Javascript

Javascript and JScript

Netscape developed the original version of Javascript for the second version of their popular browser. Initially Netscape 2 was the only browser to support a scripting language and that language (which was originally going to be called LiveScript) was given the name Javascript in an attempt to cash in on some of the publicity that Sun's Java programming language was getting at that time. While Javascript and Java are superficially alike they are completely different languages and this naming decision has caused numerous problems for beginners with both languages who continually get them confused. Just remember that Javascript is not Java (and vice versa) and you will avoid a lot of confusion.

Microsoft was attempting to capture market share from Netscape at that time and so with Internet Explorer 3 they introduced two scripting languages. Once of these they based on visual basic and was given the name VBscript. The second was a Javascript lookalike which Microsoft called JScript. In order to try to outdo Netscape, JScript had a number of additional commands and features available that were not in Javascript and also had interfaces to Microsoft's activeX functionality as well.

Since Netscape 1, Internet Explorer 2, and other early browsers didn't understand either Javascript or JScript it became a common practice to place all of the content of the script inside of an HTML comment so as to hide the script from older browsers. New browsers even if they couldn't handle scripts were designed to recognise the script tags themselves and so hiding the script by placing it in a comment was not required for any browsers released after IE3. Unfortunately by the time that the extremely early browsers ceased to be used people had forgotten the reason for the HTML comment and so many people new to Javascript still include these now completely unnecessary tags. In fact including the HTML comment can cause problems since if you use XHTML instead of HTML including the code inside a comment like that will have the effect of making the script a comment rather than a script. Many modern Content Management Systems (CMS) will do the same.

Over time both Javascript and JScript were extended to introduce new commands to improve their ability to interact with web pages. Both languages added new features that worked differently than the corresponding feature (if any) in the other language. They were just similar enough that it was possible to use browser sensing to work out whether the browser was Netscape or IE and thus to run the appropriate code for that browser. As the balance shifted toward IE gaining an equal share of the browser market with Netscape this incompatibility needed a resolution.

Netscape's solution was to hand over control of Javascript to the European Computer Manufacturers Association (ECMA). The Association formalized the Javascript standards under the name ECMAscipt. At the same time the World Wide Web Consortium (W3C) commenced work on a standard Document Object Model (DOM) that would be used to allow Javascript and other scripting languages full access to manipulate all of the content of the page instead of the limited access that it had up until that time.

Before the DOM standard was complete both Netscape and Microsoft released their own versions. Netscape 4 came with its own document.layer DOM and Internet Explorer 4 came with its own document.all DOM. Both of these document object models were made obsolete when people ceased using either of those browsers as all browsers since then have implemented the standard DOM.ECMAscript and the introduction of the standard DOM in all of the version five and more recent browsers removed most of the incompatibilities between Javascript and JScript and while these two languages still have their differences it is now possible to write code that can run both as JScript in Internet Explorer and as Javascript in all of the other modern browsers. Support for specific features may vary between browsers but we can test for those differences by making use of a feature built into both languages from the start that allows us to test if the browser supports a specific feature. By testing the specific features that not all browsers support we will be able to determine what code is appropriate to run in the current browser.

The biggest difference now between Javascript and JScript are all of the additional commands that JScript supports that allow access to activeX and the local computer. These commands are intended for use on intranet sites where you know the configuration of all of the computers and that they are all running Internet Explorer. As these extensions in JScript should not be used on the internet I will not be covering any of them in this book.There are still a few areas remaining where Javascript and JScript differ in the means that they provide to perform a particular task. Where these occur, we will look at both the javascript and the JScript processes and how to combine them both into code that will work across all modern browsers. Except in these situations the two languages can therefore be considered to be equivalent to one another and so unless otherwise specified all of the references to Javascript can also be taken to include JScript.

Post comment:

◎welcome to give out your point。

Calendar

Comments

Previous

Powered By http://www.javascriptfunction.com

Copyright http://www.javascriptfunction.com/. All Rights Reserved.