05-JavaScript.pdf - JavaScript 2018\/19 COMP3322A Modern Technologies on WWW Contents JavaScript and its history Adding JavaScript The JavaScript

05-JavaScript.pdf - JavaScript 2018/19 COMP3322A Modern...

This preview shows page 1 - 11 out of 86 pages.

JavaScript 2018/19 COMP3322A Modern Technologies on WWW
Image of page 1
Contents JavaScript and its history Adding JavaScript The JavaScript language JavaScript Objects The Document Object Model (DOM) Events Form Validation
Image of page 2
Client-Side Scripting Let the client compute
Image of page 3
What is JavaScript JavaScript runs right inside the browser. JavaScript is dynamically typed. JavaScript is object-oriented in that almost everything in the language is an object the objects in JavaScript are prototype-based rather than class-based, which means that while JavaScript shares some syntactic features of PHP, Java or C#, it is also quite different from those languages.
Image of page 4
JavaScript isn’t related to Java Although it contains the word Java , JavaScript and Java are vastly different programming languages with different uses. Java is a full- fledged compiled, object-oriented language, popular for its ability to run on any platform with a JVM installed. Conversely, JavaScript is one of the world’s most popular languages, with fewer of the object-oriented features of Java, and runs directly inside the browser, without the need for the JVM.
Image of page 5
JavaScript History JavaScript was introduced by Netscape in their Navigator browser back in 1995. JavaScript is in fact an implementation of a standardized scripting language called ECMAScript IN 1998, ECMAScript 2 was released. In 1999, ECMAScript 3 was released. Which evolved into what is today’s modern JavaScript. ECMAScript 5 was released in 2009. At the moment, ECMAScript 2018 (the 9 th edition) is the latest release. Source: Wikipedia ECMAScript
Image of page 6
Where does JavaScript go? JavaScript can be linked to an HTML page in a number of ways. Inline Embedded in the document Link to an external file When the browser encounters a block of JavaScript, it generally runs it in order, from top to bottom. This means that you need to be careful what order you put things in.
Image of page 7
Inline JavaScript Inline JavaScript refers to add the JavaScript code directly within certain HTML attributes. Inline JavaScript is a real maintenance nightmare. <a href= "JavaScript:OpenWindow();">more info< /a> <input type= "button" onclick="alert('Are you sure?');">
Image of page 8
Embedded JavaScript Embedded JavaScript refers to the practice of placing JavaScript code within a <script> element. You can place any number of scripts in an HTML document. Scripts can be placed in the <body>, or in the <head> section of an HTML page, or in both. < script > function myFunction() { document.getElementById( "demo" ).innerHTML = "Paragraph changed." ; } < /script >
Image of page 9
External JavaScript JavaScript supports this separation by allowing links to an external file that contains the JavaScript. By convention, JavaScript external files have the extension .js.
Image of page 10
Image of page 11

You've reached the end of your free preview.

Want to read all 86 pages?

  • Summer '19
  • Document Object Model

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture