JavaScript SectionJavaScript is a language with object oriented capabilities that can be used for client-side scripting on the Internet. This means that browsers that support JavaScript can run JavaScripts provided on a certain server locally after they have been downloaded. A browser that support JavaScript is supplied with a JavaScript interpreter to process the statements carried out within the several JavaScripts. In a way JavaScript can be seen as "glue" between several parts of a homepage, making the page more dynamic or in some cases interactive. JavaScript can be used for form validation for instance. It is possible to validate the values a user has entered into a web form before the form is submitted. The benefit of this approach is that already on the client-side a validation is done and if that validation fails so will the server-side validation, because at least that validation has to reside on the server-side as well. Preferably a better check will be performed on the server-side. But with client-side validation it is possible to avoid that data, which is definately incorrect is sent across the internet, validated by the server, and sent back to the user because it is wrong anyway. To make it more clear: Why submit a form to a server if on the client side already is known that the form was filled in wrong? So with client-side validation it is possible to have the user fill in proper values. Because client-side validation is not completely reliable and the user can turn off JavaScript in his browser there has to be a server-side validation as well. But at least with client-side validation you can reduce the internet traffic and ofcourse client-side validation is quicker than server-side validation. So the chance that the user will get an error message back from the server saying that the form was filled in improperly becomes smaller in that way. JavaScript often is used to make a site just look a little bit nicer. Many sites have a JavaScript menu or navigation and use mouseover images to make the page appear nicer. The control of these images often is done using JavaScript. JavaScript has some event handlers that can take care of the swapping of the images based on several events such as mouse over, mouse out or mouse pressed. The problem with JavaScript is that there are many versions available. In a way that is not bad, because for every version of JavaScript a specification is available. If the author of the JavaScript specifies in a proper way what version of JavaScript is used and the syntax and functions are used properly there shouldn't be a problem. The problem lies in the fact that the best known browsers (Microsoft Internet Explorer and Netscape) have their own interpretation of JavaScript and have added their own functions, events etc. to the language. So many solutions work in Microsoft IE and not in Netscape vice versa. As a result of this many scripts have to take this into account and have to detect what browser is used to load the script. Based on the browser certain code is executed and other code has to be skipped. At a certain point the script consists of many if-statements having to do with behaviour for a certain browser. It is very easy to detect the browser with basic JavaScript using the The Links
Contact the author: Send an electronic mail to: pajtroon@dds.nl. This page: Copyright © 2002 - 2005 Peter A. J. Troon Note: This page is part of the Peter Troon Site. |