SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Javascript
Jim Fawcett
CSE686 – Internet Programming
Summer 2010
What is Javascript?
 A programming language, supported by modern
browsers
 Script language with C-like syntax
 Intended to manipulate a webpage’s document object
 Very loosely typed
 Supports:
 Primitive types like ints, booleans, doubles
 Strings and Arrays
 User Defined Objects
 Has built-in functions:
 eval, parseInt, parseFloat, alert, getAttribute,
setAttribute, …
Typical JavaScript Applications
 Post a page, sent from some server, back to
the server with client supplied data
 Validate Form fields on client side
 Alter the style of page elements based on
mouse events
 Hide, show, and move page elements
 Manage page scrolling
 Set and retrieve cookies
What JavaScript cannot do for
reasons of security
 Cannot read or write files to the filesystem
 IIS and IE provide filesystem objects that script can
use to do that.
 Cannot execute other programs
 Cannot establish communication with another
computer other than to download a page or send
mail.
 IE provides the File object that script can use to upload
and download files.
 Cannot read the browser history
 Cannot act on the DOM of another page that did not
come from the same server.
Javascript Types
 Most Objects are reference types:
 DOM object, user-defined object, array
 Other types are value types:
 String, Number, Boolean
 Literals, e.g., “a string”, 5, true
 Everything is either a literal or an object
Strings, Numbers, and Booleans
 var s1 = “this is a literal string”;
 var s2 = new String(“this is a string object”);
 var i = 3;
 var d = 3.1415927;
 var d2 = new Number(“34.2e-3”);
 var b1 = true; // note: not “true”
 var b2 = new Boolean(false);
JavaScript Objects
 All Objects are dictionaries, e.g.,
collections of name value pairs:
 var myObj = new Object();
 myObj.name = “myObj”; // usual way
 myObj[“date”] = new Date(); // dictionary
 document.write(myObj.name + “ “);
 document.write(myObj.date);
 function aFun() { … }
 myObj.myFun = aFun; // add member func
Prototypes
 You can create a new object as a copy of an existing
object, the prototype:
 var YourObj = new myObj(“Jim”, new Date());
 You can add a property or method to a single
instance of some object:
 var myModObj = new myObj();
 myModObj.prop1 = someString;
 You can add a property or method to every instance
of an object like this:
 myModObj.prototype.prop2 = “some prop”;
Functions are Objects
 In JavaScript functions are also objects:
 Ordinary definition:
function myFun(x) { alert(x); }
myFun(“this is a message”);
 Anonymous definition:
var myFun = function(x) { alert(x); }
 Function constructor:
var myFun = new Function(“x”, “alert(x);”);
Arrays
 Three ways to create Arrays:
 var array1 = new Array(1, 1.5, 0, -1);
 var array2 = [1, 4, 9, 16, 26];
 var array3 = new Object();
array3[“pig”] = “mammal”;
array3[“snake”] = “reptile”;
array3[“platypus”] = “marsupial”;
array4[“vulture”] = “bird”;
User-Defined Objects
 Two ways to create an object:
 var myFirstObj = new Object();
 myFirstObj.name = “my_object”
 myFirstObj.func = function() { … };
 And:
 function mySecondObj(name,func)
{
this.name = name;
this.func = function() {…};
}
DOM Objects - Document
 Document
 Element
 Text
 Comment
 Attr
 …
 http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1590626202
 http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dom/
domoverview.asp
 http://www.w3schools.com/htmldom/dom_obj_document.asp
DOM Methods (most used)
 ref = document.createElement(tagName)
 ref = document.createTextNode(text)
 ref = node.cloneNode(deep)
 ref = element.appendChild(newChild)
 ref = element.insertBefore(newNode,tagetNode)
 ref = element.removeChild(node)
 ref = element.replaceChild(newChild,oldChild)
 element.setAttribute(attributeName,attributeValue)
 attributeValue = element.getAttribute(attributeName)
 element = document.getElementById(id)
 elements = document.getElementsByTagName(tag)
 boolean = element.hasChildNodes()
DOM Properties (XML only)
 Node properties
 Name = node.nodeName
 integer = node.nodeType
 1: ELEMENT_NODE
 2: ATTRIBUTE_NODE
 3: TEXT_NODE
 4: CDATA_SECTION_NODE
 5: ENTITY_REFERENCE_NODE
 6: ENTITY_NODE
 7: PROCESSING_INSTRUCTION_NODE
 8: COMMENT_NODE
 9: DOCUMENT_NODE
 10: DOCUMENT_TYPE_NODE
 11: DOCUMENT_FRAGMENT_NODE
 12: NOTATION_NODE
 Value = node.nodeValue
 nodeList = node.childNodes
 Ref = node.firstChild
 Ref = node.lastChild
 Ref = node.nextSibling
 Ref = node.parentNode
 Ref = node.previousSibling
Window Properties (partial list)
 closed
 document
 frames[]
 location (url)
 name
 navigator
 parent
 screen
Window Methods (partial list)
 Alert() – dialog box
 Close() – close window
 Confirm() – dialog box
 Focus() – set focus
 moveBy() – move relative to current position
 moveTo() – move to new screen location
 Open() – open new window
 Prompt() – dialog box
 setInterval() – execute code periodically
 setTimeout() – execute code after a specified time
References
 ppk on Javascript, New Riders, 2007
 Learning JavaScript, Shelly Powers, O’Reilly, 2007
 Javascript, the Definitive Guide, David Flanagan,
O’Reilly, 2002
 DOM Scripting, Jeremy Keith, Apress, 2005
 Javascript & DHTML Cookbook, Danny
Goodman,O’Reilly, 2003
 HTML & XHTML, the Definitive Guide, Musciano &
Kennedy, O’Reilly, 2002
 Cascading Style Sheets, the Definitive Guide, Eric
Meyer, O’Reilly, 2000
 www.devguru.com

Weitere ähnliche Inhalte

Ähnlich wie Javascript.ppt

12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objectsPhúc Đỗ
 
Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojoyoavrubin
 
Document Object Model
Document Object ModelDocument Object Model
Document Object ModelMayur Mudgal
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScriptLilia Sfaxi
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slideshelenmga
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script AdvanceJaya Kumari
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance TipsRavi Raj
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...SPTechCon
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptWalid Ashraf
 
Intoduction on Playframework
Intoduction on PlayframeworkIntoduction on Playframework
Intoduction on PlayframeworkKnoldus Inc.
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - ObjectsWebStackAcademy
 
Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Ayes Chinmay
 

Ähnlich wie Javascript.ppt (20)

12. session 12 java script objects
12. session 12   java script objects12. session 12   java script objects
12. session 12 java script objects
 
JS basics
JS basicsJS basics
JS basics
 
Introduction To Dojo
Introduction To DojoIntroduction To Dojo
Introduction To Dojo
 
Mdst 3559-02-10-jquery
Mdst 3559-02-10-jqueryMdst 3559-02-10-jquery
Mdst 3559-02-10-jquery
 
Reversing JavaScript
Reversing JavaScriptReversing JavaScript
Reversing JavaScript
 
2.java script dom
2.java script  dom2.java script  dom
2.java script dom
 
JavaScript
JavaScriptJavaScript
JavaScript
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Client-side JavaScript
Client-side JavaScriptClient-side JavaScript
Client-side JavaScript
 
Jquery dojo slides
Jquery dojo slidesJquery dojo slides
Jquery dojo slides
 
Java script Advance
Java script   AdvanceJava script   Advance
Java script Advance
 
Web Performance Tips
Web Performance TipsWeb Performance Tips
Web Performance Tips
 
Javascript
Javascript Javascript
Javascript
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
 
Automating Ievb
Automating IevbAutomating Ievb
Automating Ievb
 
Web 6 | JavaScript DOM
Web 6 | JavaScript DOMWeb 6 | JavaScript DOM
Web 6 | JavaScript DOM
 
Intoduction on Playframework
Intoduction on PlayframeworkIntoduction on Playframework
Intoduction on Playframework
 
JavaScript - Chapter 8 - Objects
 JavaScript - Chapter 8 - Objects JavaScript - Chapter 8 - Objects
JavaScript - Chapter 8 - Objects
 
Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM] Internet and Web Technology (CLASS-6) [BOM]
Internet and Web Technology (CLASS-6) [BOM]
 

Kürzlich hochgeladen

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 

Kürzlich hochgeladen (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 

Javascript.ppt

  • 1. Javascript Jim Fawcett CSE686 – Internet Programming Summer 2010
  • 2. What is Javascript?  A programming language, supported by modern browsers  Script language with C-like syntax  Intended to manipulate a webpage’s document object  Very loosely typed  Supports:  Primitive types like ints, booleans, doubles  Strings and Arrays  User Defined Objects  Has built-in functions:  eval, parseInt, parseFloat, alert, getAttribute, setAttribute, …
  • 3. Typical JavaScript Applications  Post a page, sent from some server, back to the server with client supplied data  Validate Form fields on client side  Alter the style of page elements based on mouse events  Hide, show, and move page elements  Manage page scrolling  Set and retrieve cookies
  • 4. What JavaScript cannot do for reasons of security  Cannot read or write files to the filesystem  IIS and IE provide filesystem objects that script can use to do that.  Cannot execute other programs  Cannot establish communication with another computer other than to download a page or send mail.  IE provides the File object that script can use to upload and download files.  Cannot read the browser history  Cannot act on the DOM of another page that did not come from the same server.
  • 5. Javascript Types  Most Objects are reference types:  DOM object, user-defined object, array  Other types are value types:  String, Number, Boolean  Literals, e.g., “a string”, 5, true  Everything is either a literal or an object
  • 6. Strings, Numbers, and Booleans  var s1 = “this is a literal string”;  var s2 = new String(“this is a string object”);  var i = 3;  var d = 3.1415927;  var d2 = new Number(“34.2e-3”);  var b1 = true; // note: not “true”  var b2 = new Boolean(false);
  • 7. JavaScript Objects  All Objects are dictionaries, e.g., collections of name value pairs:  var myObj = new Object();  myObj.name = “myObj”; // usual way  myObj[“date”] = new Date(); // dictionary  document.write(myObj.name + “ “);  document.write(myObj.date);  function aFun() { … }  myObj.myFun = aFun; // add member func
  • 8. Prototypes  You can create a new object as a copy of an existing object, the prototype:  var YourObj = new myObj(“Jim”, new Date());  You can add a property or method to a single instance of some object:  var myModObj = new myObj();  myModObj.prop1 = someString;  You can add a property or method to every instance of an object like this:  myModObj.prototype.prop2 = “some prop”;
  • 9. Functions are Objects  In JavaScript functions are also objects:  Ordinary definition: function myFun(x) { alert(x); } myFun(“this is a message”);  Anonymous definition: var myFun = function(x) { alert(x); }  Function constructor: var myFun = new Function(“x”, “alert(x);”);
  • 10. Arrays  Three ways to create Arrays:  var array1 = new Array(1, 1.5, 0, -1);  var array2 = [1, 4, 9, 16, 26];  var array3 = new Object(); array3[“pig”] = “mammal”; array3[“snake”] = “reptile”; array3[“platypus”] = “marsupial”; array4[“vulture”] = “bird”;
  • 11. User-Defined Objects  Two ways to create an object:  var myFirstObj = new Object();  myFirstObj.name = “my_object”  myFirstObj.func = function() { … };  And:  function mySecondObj(name,func) { this.name = name; this.func = function() {…}; }
  • 12. DOM Objects - Document  Document  Element  Text  Comment  Attr  …  http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1590626202  http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dom/ domoverview.asp  http://www.w3schools.com/htmldom/dom_obj_document.asp
  • 13. DOM Methods (most used)  ref = document.createElement(tagName)  ref = document.createTextNode(text)  ref = node.cloneNode(deep)  ref = element.appendChild(newChild)  ref = element.insertBefore(newNode,tagetNode)  ref = element.removeChild(node)  ref = element.replaceChild(newChild,oldChild)  element.setAttribute(attributeName,attributeValue)  attributeValue = element.getAttribute(attributeName)  element = document.getElementById(id)  elements = document.getElementsByTagName(tag)  boolean = element.hasChildNodes()
  • 14. DOM Properties (XML only)  Node properties  Name = node.nodeName  integer = node.nodeType  1: ELEMENT_NODE  2: ATTRIBUTE_NODE  3: TEXT_NODE  4: CDATA_SECTION_NODE  5: ENTITY_REFERENCE_NODE  6: ENTITY_NODE  7: PROCESSING_INSTRUCTION_NODE  8: COMMENT_NODE  9: DOCUMENT_NODE  10: DOCUMENT_TYPE_NODE  11: DOCUMENT_FRAGMENT_NODE  12: NOTATION_NODE  Value = node.nodeValue  nodeList = node.childNodes  Ref = node.firstChild  Ref = node.lastChild  Ref = node.nextSibling  Ref = node.parentNode  Ref = node.previousSibling
  • 15. Window Properties (partial list)  closed  document  frames[]  location (url)  name  navigator  parent  screen
  • 16. Window Methods (partial list)  Alert() – dialog box  Close() – close window  Confirm() – dialog box  Focus() – set focus  moveBy() – move relative to current position  moveTo() – move to new screen location  Open() – open new window  Prompt() – dialog box  setInterval() – execute code periodically  setTimeout() – execute code after a specified time
  • 17. References  ppk on Javascript, New Riders, 2007  Learning JavaScript, Shelly Powers, O’Reilly, 2007  Javascript, the Definitive Guide, David Flanagan, O’Reilly, 2002  DOM Scripting, Jeremy Keith, Apress, 2005  Javascript & DHTML Cookbook, Danny Goodman,O’Reilly, 2003  HTML & XHTML, the Definitive Guide, Musciano & Kennedy, O’Reilly, 2002  Cascading Style Sheets, the Definitive Guide, Eric Meyer, O’Reilly, 2000  www.devguru.com