11.03.07
Introduction to JavaScript
JavaScript is the premier scripting language on the Internet. It is the easiest way for programmers to do browser scripting. In order to be any kind of good Webmaster, you need to know how to use JavaScript. This oracle will introduce you to the most basic JavaScript imaginable.
Before we can start explaining how JavaScript works, you should see an example of JavaScript in work. The example below is the most basic JavaScript imaginable.
<Script type =”text/javascript”>
document.write(“Hello World!”)
</script>
Because of the words Hello World located with in the middle of the script, you have probably already guessed what this JavaScript is intended to do. Just in case you have not, this particular piece of JavaScript is intended to say the words Hello World on screen. In order to understand exactly how this piece of script works, it is important first to understand what each individual element of it does. In order to explain the, let us examine each individual line of code separately.
<script type=”text/javascript”>
This first line of script is not actually a JavaScript piece of code. It is a piece of HTML code. The main code being used here is the script code. The script code is responsible for letting the computer know that the upcoming lines of code are going to be JavaScript code.
document.write(“Hello World!”)
The second line of script is the actual JavaScript in this code. It is the line that is responsible for letting the browser know that the words Hello World need to be displayed in the browser, with the exclamation mark at the end. Ultimately, it is this line that represents what is actually happening in the actual coding world.
</script>
The final line closes the JavaScript at the end, letting the browser know that the JavaScript code is done for the moment. In other words, the <script> and </script> tags delineate a specific area within which JavaScript code is used. This code is used in order to let the document.write command be recognized as JavaScript, rather than be recognized as something else. If the <script> and </script> tags were not there, then the most likely resolution would have been that the words “document.write(“Hello World!”)” would actually have appeared in the browser, since it had no way of recognizing them as JavaScript rather than as text to be displayed. In the future, all JavaScript that you choose to include will need to be delineated with <script> and </script> tags.
Scriptycan is a great software repository featuring both free and commercial Java script scripts and applications for developers and programmers.