Docsity

Exploring Java Script - Introduction to Java Script - Lecture Slides, Slides of Javascript programming

Partial preview of the text

Download Exploring Java Script - Introduction to Java Script - Lecture Slides and more Slides Javascript programming in PDF only on Docsity!

Exploring JavaScript

Hello World

One Paragraph

Your browser doesn't support or has disabled JavaScript.

Second Paragraph

js-01.htm

Hello World

One Paragraph

Your browser doesn't support or has disabled JavaScript.

Second Paragraph

js-02.htm

Including JavaScript

• Three Patterns

• As part of an event (i.e. onclick) in an HTML tag

• Inline within the document

• From a file

Hello World

One Paragraph

Second Paragraph

JavaScript inline that will pass validation

Hello World

One Paragraph

Third Paragraph

script.js: document.write("

Hello World

"); JavaScript in a separate file js-04.htm

One Paragraph

Two Paragraph

Three Paragraph

js-05.htm

Seeing the Error

• Since the end-user really cannot take any action to fix the

JavaScript coming as part of a web page, the browser eats the errors.

• As a developer, we need to look for the errors - sometimes it takes

a minute to even remember to check for a JS error

Console Logging

• Debugging using alert() can get tiring - sometimes you want to

record what happens in case something goes wrong

• http://getfirebug.com/logging

• console.log("String") - and many more functions

• Note: Requires recent browsers

One Paragraph

Two Paragraph

Three Paragraph

js-06.htm

Using the Debugger

• Add the FireBug FireFox Extension

• Enable FireBug, reload

• Set Breakpoint, and reload again