VirtualMV/JavaScript/JS and HTML

From WikiEducator
Jump to: navigation, search




Introduction

Overview

VmvIcon Objectives.png

By the end of this page you will be able to:

  • Understand how JavaScript and HTML are related

JavaScript and HTML

  • When a JavaScript is inserted into an HTML document, the Internet browser will read the HTML and interpret the JavaScript. The JavaScript can be executed immediately, or at a later event, depending how and where it is placed.
  • To add JavaScript to an HTML page enclose code between
<script type="text/javascript">
</script>
  • Note. You may find <script language ="Javascript"> in code you see on the Internet. The language attribute has been deprecated so avoid using it in your code.
  • Example HTML page with JavaScript
<html>
  <head></head>
  <body>
    <script type="text/javascript">      <!--       document.write('<h1>Hello world.. JavaScript rulz!</h1>');    //-->    </script>  </body>
</html>

Example : Click here to run js1_01. The diagram following shows the result in Google's chrome.

JavaScript: Hello World (in Google's Chrome Web Browser)

VmvIcon References.png References

virtualMV  |  Superquick wiki guide  |  Please give me some feedback

VirtualMV/JavaScript/JS and HTML. (2024). In WikiEducator/VirtualMV wiki. Retrieved November 21, 2024, from http:https://wikieducator.org/VirtualMV/JavaScript/JS_and_HTML    (zotero)