A Beginning Look at JavaScript.
JavaScript has been in use almost as long as HTML itself. The main use of JavaScript is to add some dynamic behavior to websites, which means seeing results without having to wait for a page to refresh itself every time there is a change.
The main use of JavaScript in web pages adds the ability to:
- Dynamically generate HTML code into your webpage.
- Setup responses to events, like page loads and user clicks.
- Form Validation—JavaScript can code can check the information in the input fields is present and in the correct format.
- JavaScript can detect what web browser you are using and change to a webpage made for that browser. This used to be more important than it is now.
- JavaScript can be used in the passage and storage of information in cookies. This is usually the result of filling out a web form.
To use JavaScript, one embeds scripting code into the HTML code of their web page. A basic example would be that of dynamically writing test. Normally this would be apart of an function called on a page load or if a button was clicked, but for the purpose of the example, this code is just in the body of the page and will run when the page is first loaded up.
<html>
<body>
<script type= “text/javascript”>
document.write(“document is the current web page being viewed. The red text is just for effect”);
</script>
</body>
</html>
c35062bb-77a3-4cd0-bfec-0bd019579944|0|.0