document.write("Hello World”) "> document.write("Hello World”) ">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exploring JavaScript Ch 14

Similar presentations


Presentation on theme: "Exploring JavaScript Ch 14"— Presentation transcript:

1 Exploring JavaScript Ch 14
JavaScript brings a dynamic functionality to your websites

2 JavaScript and HTML Text
A typical HTML 4.01 “Hello World” document using JavaScript might look like Example14-1. Example “Hello World” displayed using JavaScript <html> <head><title>Hello World</title></head> <body> <script type="text/javascript”> document.write("Hello World”) </script> <noscript> Your browser doesn't support or has disabled JavaScript </noscript> </body> </html>

3 Using Scripts Within a Document Head
you can put it in the <head> section Old and non Standard Browsers Other scripting languages Microsoft’s VBScript, which is based on the Visual Basic programming language and Tcl, a rapid prototyping language

4 Including JavaScript Files
In addition to writing JavaScript code directly in HTML documents, you can include files of JavaScript code either from your website or from anywhere on the Internet. The syntax for this is <script type="text/javascript" src="script.js"></script> To pull a file in from the Internet, use <script type="text/javascript" src=

5 Debugging JavaScript Errors

6 Using Comments // This is a comment /* This is a section of multiline comments that will not be interpreted */

7 Semicolons Not generally required by JavaScript if you have only one statement on a line

8 Variables, String Variables
No particular character identifies a variable in JavaScript as the dollar sign does in PHP JavaScript string variables should be enclosed in either single or double quotation marks, like this: greeting = "Hello there” warning = 'Be careful’

9 Operators, Arithmetic Operators
JavaScript mathematical operators look a lot like plain arithmetic

10 Assignment Operators

11 Comparison Operators

12 Logical Operators do not include and and or equivalents to && and ||, and there is no xor operator

13 Variable Typing

14 Functions, Global Variables
As with PHP, JavaScript functions are used to separate out sections of code that perform a particular task see 14-9 Global variables are ones defined outside of any functions (or within functions, but defined without the var keyword).

15 Local Variables Parameters passed to a function automatically have local scope see example 14-10, and 14-12

16 The Document Object Model
Document Object Model or DOM. This breaks down the parts of an HTML document into discrete objects, each with its own properties and methods, and each subject to JavaScript’s control.

17 DOM Object Hierarchy


Download ppt "Exploring JavaScript Ch 14"

Similar presentations


Ads by Google