client side programming ( events & dom)

28
Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Upload: salaam

Post on 10-Jan-2016

39 views

Category:

Documents


3 download

DESCRIPTION

Web Application Development. Client Side Programming ( Events & DOM). Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College. Event Driven Paradigm. Action Event Handling ( Also called as handler ) Function. Functions. function anyFunction () { alert(“Inside anyFunction”); } - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Client Side Programming ( Events & DOM)

Web Application Development

Muhammad AliVersonic Pte

Asher ImtiazForman Christian College

Page 2: Client Side Programming ( Events & DOM)

Action

Event

Handling (Also called as handler) Function

Page 3: Client Side Programming ( Events & DOM)

function anyFunction() {alert(“Inside anyFunction”);

}

function sum(num1, num2) {return num1 + num2;

}

Page 4: Client Side Programming ( Events & DOM)

function calculateGrade(marks) {

if (marks >= 90 && marks <= 100) {return “A”;

} else if (marks >= 80) {

return “B”;}

else if (marks >= 70) {return “Pass”;

}}

Page 5: Client Side Programming ( Events & DOM)

API (Application Programming Interface) For how JavaScript Programs can access

and manipulate the HTML Document

DOM Standardization

Page 6: Client Side Programming ( Events & DOM)

▪ DOM – 1 (1998)▪ Complete model for an entire HTML or XML document,

including means to change any portion of the document.

▪ DOM-2 (late 2000)▪ getElementById▪ Event model▪ CSS

▪ DOM-3▪ Xpath▪ Keyboard Event Handling

Page 7: Client Side Programming ( Events & DOM)

source: wikipedia

Page 8: Client Side Programming ( Events & DOM)

source: wikipedia

Page 9: Client Side Programming ( Events & DOM)
Page 10: Client Side Programming ( Events & DOM)

source: wikipedia

Page 11: Client Side Programming ( Events & DOM)

source: wikipedia

Page 12: Client Side Programming ( Events & DOM)

source: w3schools

Page 13: Client Side Programming ( Events & DOM)

source: w3schools

Page 14: Client Side Programming ( Events & DOM)

source: w3schools

Page 15: Client Side Programming ( Events & DOM)

source: w3schools

Page 16: Client Side Programming ( Events & DOM)

Detecting Browser Version

navigator.appName

navigator.appVersion navigator.userAgent

Page 17: Client Side Programming ( Events & DOM)

<html><head>

<title>My Title</title></head><body>

<a href="someFile.html">My link</a>

<h1>My header</h1></body>

</html>

Page 18: Client Side Programming ( Events & DOM)

Source: w3schools.com

Page 19: Client Side Programming ( Events & DOM)

getElementByTagId

getElementsByTagName

Traverse the DOM Tree

Page 20: Client Side Programming ( Events & DOM)

function addElement() { var newdiv = document.createElement(“div”);

newdiv.setAttribute(“id”,”myDiv”); newdiv.innerHTML = “Element added!”;

}

Page 21: Client Side Programming ( Events & DOM)

function removeElement(divToRemove) {

var parentDiv = document.getElementById('myDiv');

parentDiv.removeChild(divToRemove); }

Page 22: Client Side Programming ( Events & DOM)

var button = window.getElementById(“msgButton”);

button.addEventListener(“click”, sayHello, false);

function sayHello() {window.alert(“Hello”);

}

Page 23: Client Side Programming ( Events & DOM)

removeEventListener The event listener will no longer exist!

Page 24: Client Side Programming ( Events & DOM)

Quirksmode - DOM Traversal[http://www.quirksmode.org/dom/intro.html ]

w3schools - DOM Tutorials [http://www.w3schools.com/HTMLDOM/dom_examples.asp]

MREDKJ - DOM Tutorials[http://www.mredkj.com/tutorials/htmljs.html]

Page 25: Client Side Programming ( Events & DOM)

Sets the timeout for the function var tid = setTimeout("timedCount()",

1000);

Clears the timout clearTimeout(tid);

Page 26: Client Side Programming ( Events & DOM)

Aptana Debugger

Firebug Extension for Firefox

Page 27: Client Side Programming ( Events & DOM)

Breakpoints

Call Stack

Watch & Inspect

Step-into, Step-over, Step-out

Page 28: Client Side Programming ( Events & DOM)