web application development muhammad ali versonic pte asher imtiaz forman christian college

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

Upload: silas-george

Post on 23-Dec-2015

221 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Web Application Development

Muhammad AliVersonic Pte

Asher ImtiazForman Christian College

Page 2: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Action

Event

Handling (Also called as handler) Function

Page 3: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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

}

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

}

Page 4: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

function calculateGrade(marks) {

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

} else if (marks >= 80) {

return “B”;}

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

}}

Page 5: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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

and manipulate the HTML Document

DOM Standardization

Page 6: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

▪ 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: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: wikipedia

Page 8: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: wikipedia

Page 9: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College
Page 10: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: wikipedia

Page 11: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: wikipedia

Page 12: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: w3schools

Page 13: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: w3schools

Page 14: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: w3schools

Page 15: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

source: w3schools

Page 16: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Detecting Browser Version

navigator.appName

navigator.appVersion navigator.userAgent

Page 17: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

<html><head>

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

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

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

</html>

Page 18: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Source: w3schools.com

Page 19: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

getElementByTagId

getElementsByTagName

Traverse the DOM Tree

Page 20: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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

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

}

Page 21: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

function removeElement(divToRemove) {

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

parentDiv.removeChild(divToRemove); }

Page 22: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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

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

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

}

Page 23: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

removeEventListener The event listener will no longer exist!

Page 24: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

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

1000);

Clears the timout clearTimeout(tid);

Page 26: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Aptana Debugger

Firebug Extension for Firefox

Page 27: Web Application Development Muhammad Ali Versonic Pte Asher Imtiaz Forman Christian College

Breakpoints

Call Stack

Watch & Inspect

Step-into, Step-over, Step-out

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