├── LICENSE.txt ├── 9781430233893.jpg ├── chapter09 ├── story │ ├── styles │ │ └── format.css │ ├── scripts │ │ ├── addLoadEvent.js │ │ └── styleHeaderSiblings.js │ └── story.html ├── itinerary │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── highlightRows.js │ │ ├── stripeTables.js │ │ └── displayAbbreviations.js │ ├── styles │ │ └── format.css │ └── itinerary.html └── example.html ├── images ├── background.gif ├── domscripting_small.gif └── webdesignwiththedom.gif ├── styles ├── basic.css ├── layout.css ├── colour.css └── typography.css ├── chapter10 ├── slideshow │ ├── topics.gif │ ├── styles │ │ └── layout.css │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── moveElement.js │ │ └── prepareSlideshow.js │ └── list.html ├── slideshow2 │ ├── topics.gif │ ├── styles │ │ └── layout.css │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── insertAfter.js │ │ ├── prepareSlideshow.js │ │ └── moveElement.js │ └── list.html ├── message │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── positionMessage.js │ │ └── moveElement.js │ └── message.html └── test.html ├── chapter12 └── domsters │ ├── styles │ ├── basic.css │ ├── typography.css │ ├── color.css │ └── layout.css │ ├── images │ ├── logo.gif │ ├── bassist.gif │ ├── drummer.gif │ ├── frame.gif │ ├── lineup.gif │ ├── loading.gif │ ├── navbar.gif │ ├── basshead.gif │ ├── guitarist.gif │ ├── portrait.gif │ ├── slideshow.gif │ ├── background.gif │ ├── photos │ │ ├── crowd.jpg │ │ ├── bassist.jpg │ │ ├── concert.jpg │ │ ├── guitarist.jpg │ │ ├── thumbnail_crowd.jpg │ │ ├── thumbnail_bassist.jpg │ │ ├── thumbnail_concert.jpg │ │ └── thumbnail_guitarist.jpg │ └── placeholder.gif │ ├── scripts │ ├── ajax.js │ ├── modernizr-1.6.min.js │ └── global.js │ ├── submit.html │ ├── index.html │ ├── contact.html │ ├── template.html │ ├── photos.html │ ├── live.html │ └── about.html ├── chapter04 └── image_gallery │ ├── 01 │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ └── fireworks.jpg │ └── gallery.html │ ├── 02 │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ ├── fireworks.jpg │ │ └── placeholder.gif │ ├── scripts │ │ └── showPic.js │ └── gallery.html │ ├── 03 │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ ├── fireworks.jpg │ │ └── placeholder.gif │ ├── scripts │ │ └── showPic.js │ └── gallery.html │ └── 04 │ ├── images │ ├── rose.jpg │ ├── bigben.jpg │ ├── coffee.jpg │ ├── fireworks.jpg │ └── placeholder.gif │ ├── scripts │ └── showPic.js │ ├── styles │ └── layout.css │ └── gallery.html ├── chapter06 └── image_gallery │ ├── 01 │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ ├── fireworks.jpg │ │ └── placeholder.gif │ ├── gallery.html │ └── scripts │ │ └── showPic.js │ ├── 02 │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ ├── fireworks.jpg │ │ ├── placeholder.gif │ │ ├── thumbnail_rose.jpg │ │ ├── thumbnail_bigben.jpg │ │ ├── thumbnail_coffee.jpg │ │ └── thumbnail_fireworks.jpg │ ├── styles │ │ └── layout.css │ ├── gallery.html │ └── scripts │ │ └── showPic.js │ └── 03 │ ├── images │ ├── rose.jpg │ ├── bigben.jpg │ ├── coffee.jpg │ ├── fireworks.jpg │ ├── placeholder.gif │ ├── thumbnail_rose.jpg │ ├── thumbnail_bigben.jpg │ ├── thumbnail_coffee.jpg │ └── thumbnail_fireworks.jpg │ ├── styles │ └── layout.css │ ├── gallery.html │ └── scripts │ └── showPic.js ├── chapter07 ├── 10 │ ├── test.html │ └── example.js ├── image_gallery │ ├── 01 │ │ ├── images │ │ │ ├── rose.jpg │ │ │ ├── bigben.jpg │ │ │ ├── coffee.jpg │ │ │ ├── fireworks.jpg │ │ │ ├── placeholder.gif │ │ │ ├── thumbnail_rose.jpg │ │ │ ├── thumbnail_bigben.jpg │ │ │ ├── thumbnail_coffee.jpg │ │ │ └── thumbnail_fireworks.jpg │ │ ├── styles │ │ │ └── layout.css │ │ ├── gallery.html │ │ └── scripts │ │ │ └── showPic.js │ ├── 02 │ │ ├── images │ │ │ ├── rose.jpg │ │ │ ├── bigben.jpg │ │ │ ├── coffee.jpg │ │ │ ├── fireworks.jpg │ │ │ ├── placeholder.gif │ │ │ ├── thumbnail_rose.jpg │ │ │ ├── thumbnail_bigben.jpg │ │ │ ├── thumbnail_coffee.jpg │ │ │ └── thumbnail_fireworks.jpg │ │ ├── styles │ │ │ └── layout.css │ │ ├── gallery.html │ │ └── scripts │ │ │ └── showPic.js │ ├── 03 │ │ ├── images │ │ │ ├── rose.jpg │ │ │ ├── bigben.jpg │ │ │ ├── coffee.jpg │ │ │ ├── fireworks.jpg │ │ │ ├── placeholder.gif │ │ │ ├── thumbnail_rose.jpg │ │ │ ├── thumbnail_bigben.jpg │ │ │ ├── thumbnail_coffee.jpg │ │ │ └── thumbnail_fireworks.jpg │ │ ├── styles │ │ │ └── layout.css │ │ ├── gallery.html │ │ └── scripts │ │ │ └── showPic.js │ └── 04 │ │ ├── images │ │ ├── rose.jpg │ │ ├── bigben.jpg │ │ ├── coffee.jpg │ │ ├── fireworks.jpg │ │ ├── placeholder.gif │ │ ├── thumbnail_rose.jpg │ │ ├── thumbnail_bigben.jpg │ │ ├── thumbnail_coffee.jpg │ │ └── thumbnail_fireworks.jpg │ │ ├── styles │ │ └── layout.css │ │ ├── gallery.html │ │ └── scripts │ │ └── showPic.js ├── 03 │ ├── example.js │ └── test.html ├── 02 │ ├── example.js │ └── test.html ├── 04 │ ├── example.js │ └── test.html ├── 06 │ ├── example.js │ └── test.html ├── 05 │ ├── example.js │ └── test.html ├── 07 │ ├── example.js │ └── test.html ├── 08 │ ├── example.js │ └── test.html ├── 09 │ ├── test.html │ └── example.js └── 01 │ └── test.html ├── chapter11 ├── 2. canvas grayscale image │ ├── images │ │ └── avatar.png │ ├── grayscale.html │ └── scripts │ │ ├── grayscale.js │ │ └── modernizr-1.6.min.js ├── 1. canvas simple │ ├── canvas.html │ ├── canvas.js │ └── canvas.svg ├── 3. video custom controls │ ├── styles │ │ └── player.css │ ├── player.html │ └── scripts │ │ ├── player.js │ │ └── modernizr-1.6.min.js └── 4. forms │ ├── examples.html │ └── modernizr-1.6.min.js ├── chapter08 ├── accesskeys │ ├── styles │ │ └── typography.css │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── displayCitations.js │ │ ├── displayAccesskeys.js │ │ └── displayAbbreviations.js │ └── explanation.html ├── citations │ ├── styles │ │ └── typography.css │ ├── scripts │ │ ├── addLoadEvent.js │ │ ├── displayCitations.js │ │ └── displayAbbreviations.js │ └── explanation.html └── abbreviations │ ├── styles │ └── typography.css │ ├── scripts │ ├── addLoadEvent.js │ └── displayAbbreviations.js │ └── explanation.html ├── README.txt ├── README.md ├── contributing.md ├── chapter05 └── example.html ├── chapter03 └── test.html └── index.html /LICENSE.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/LICENSE.txt -------------------------------------------------------------------------------- /9781430233893.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/9781430233893.jpg -------------------------------------------------------------------------------- /chapter09/story/styles/format.css: -------------------------------------------------------------------------------- 1 | .intro { 2 | font-weight: bold; 3 | font-size: 1.2em; 4 | } -------------------------------------------------------------------------------- /images/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/images/background.gif -------------------------------------------------------------------------------- /styles/basic.css: -------------------------------------------------------------------------------- 1 | @import url(typography.css); 2 | @import url(colour.css); 3 | @import url(layout.css); -------------------------------------------------------------------------------- /images/domscripting_small.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/images/domscripting_small.gif -------------------------------------------------------------------------------- /chapter10/slideshow/topics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter10/slideshow/topics.gif -------------------------------------------------------------------------------- /chapter10/slideshow2/topics.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter10/slideshow2/topics.gif -------------------------------------------------------------------------------- /chapter12/domsters/styles/basic.css: -------------------------------------------------------------------------------- 1 | @import url(color.css); 2 | @import url(layout.css); 3 | @import url(typography.css); -------------------------------------------------------------------------------- /images/webdesignwiththedom.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/images/webdesignwiththedom.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/logo.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/bassist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/bassist.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/drummer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/drummer.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/frame.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/frame.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/lineup.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/lineup.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/loading.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/loading.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/navbar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/navbar.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/basshead.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/basshead.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/guitarist.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/guitarist.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/portrait.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/portrait.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/slideshow.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/slideshow.gif -------------------------------------------------------------------------------- /chapter04/image_gallery/01/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/01/images/rose.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/02/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/02/images/rose.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/03/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/03/images/rose.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/04/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/04/images/rose.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/01/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/01/images/rose.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/rose.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/rose.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/background.gif -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/crowd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/crowd.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/placeholder.gif -------------------------------------------------------------------------------- /chapter04/image_gallery/01/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/01/images/bigben.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/01/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/01/images/coffee.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/02/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/02/images/bigben.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/02/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/02/images/coffee.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/03/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/03/images/bigben.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/03/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/03/images/coffee.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/04/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/04/images/bigben.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/04/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/04/images/coffee.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/01/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/01/images/bigben.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/01/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/01/images/coffee.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/bigben.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/coffee.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/bigben.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/coffee.jpg -------------------------------------------------------------------------------- /chapter07/03/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var testdiv = document.getElementById("testdiv"); 3 | alert(testdiv.innerHTML); 4 | } -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/coffee.jpg -------------------------------------------------------------------------------- /chapter10/slideshow/styles/layout.css: -------------------------------------------------------------------------------- 1 | #slideshow { 2 | width: 100px; 3 | height: 100px; 4 | position: relative; 5 | overflow: hidden; 6 | } -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/bassist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/bassist.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/concert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/concert.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/01/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/01/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/02/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/02/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/03/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/03/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/04/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/04/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/01/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/01/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/fireworks.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/guitarist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/guitarist.jpg -------------------------------------------------------------------------------- /chapter04/image_gallery/02/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/02/images/placeholder.gif -------------------------------------------------------------------------------- /chapter04/image_gallery/03/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/03/images/placeholder.gif -------------------------------------------------------------------------------- /chapter04/image_gallery/04/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter04/image_gallery/04/images/placeholder.gif -------------------------------------------------------------------------------- /chapter06/image_gallery/01/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/01/images/placeholder.gif -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/placeholder.gif -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/placeholder.gif -------------------------------------------------------------------------------- /chapter07/02/example.js: -------------------------------------------------------------------------------- 1 | function insertParagraph(text) { 2 | var str = "

"; 3 | str += text; 4 | str += "

"; 5 | document.write(str); 6 | } 7 | -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/placeholder.gif -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/placeholder.gif -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/placeholder.gif -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/placeholder.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/placeholder.gif -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/thumbnail_rose.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/thumbnail_rose.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/thumbnail_crowd.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/thumbnail_crowd.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/thumbnail_bigben.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/thumbnail_bigben.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/thumbnail_coffee.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/thumbnail_coffee.jpg -------------------------------------------------------------------------------- /chapter11/2. canvas grayscale image/images/avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter11/2. canvas grayscale image/images/avatar.png -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/thumbnail_bassist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/thumbnail_bassist.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/thumbnail_concert.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/thumbnail_concert.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/02/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/02/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter06/image_gallery/03/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter06/image_gallery/03/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/01/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/01/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/02/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/02/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/03/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/03/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter07/image_gallery/04/images/thumbnail_fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter07/image_gallery/04/images/thumbnail_fireworks.jpg -------------------------------------------------------------------------------- /chapter12/domsters/images/photos/thumbnail_guitarist.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apress/dom-scripting-10/HEAD/chapter12/domsters/images/photos/thumbnail_guitarist.jpg -------------------------------------------------------------------------------- /styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 1em 10%; 3 | background-attachment: fixed; 4 | } 5 | 6 | #container { 7 | position: relative; 8 | padding: 2em 5%; 9 | } 10 | -------------------------------------------------------------------------------- /chapter07/04/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var testdiv = document.getElementById("testdiv"); 3 | testdiv.innerHTML="

I inserted this content.

"; 4 | } -------------------------------------------------------------------------------- /chapter07/06/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var testdiv = document.getElementById("testdiv"); 4 | testdiv.appendChild(para); 5 | } 6 | -------------------------------------------------------------------------------- /chapter10/slideshow2/styles/layout.css: -------------------------------------------------------------------------------- 1 | #slideshow { 2 | width: 100px; 3 | height: 100px; 4 | position: relative; 5 | overflow: hidden; 6 | } 7 | #preview { 8 | position: absolute; 9 | } -------------------------------------------------------------------------------- /chapter06/image_gallery/02/styles/layout.css: -------------------------------------------------------------------------------- 1 | #imagegallery { 2 | list-style: none; 3 | } 4 | 5 | #imagegallery li { 6 | display: inline; 7 | } 8 | 9 | #imagegallery li a img { 10 | border: 0; 11 | } -------------------------------------------------------------------------------- /chapter08/accesskeys/styles/typography.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",sans-serif; 3 | font-size: 10pt; 4 | } 5 | abbr { 6 | text-decoration: none; 7 | border: 0; 8 | font-style: normal; 9 | } -------------------------------------------------------------------------------- /chapter08/citations/styles/typography.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",sans-serif; 3 | font-size: 10pt; 4 | } 5 | abbr { 6 | text-decoration: none; 7 | border: 0; 8 | font-style: normal; 9 | } -------------------------------------------------------------------------------- /chapter08/abbreviations/styles/typography.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",sans-serif; 3 | font-size: 10pt; 4 | } 5 | abbr { 6 | text-decoration: none; 7 | border: 0; 8 | font-style: normal; 9 | } -------------------------------------------------------------------------------- /chapter04/image_gallery/02/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function showPic(whichpic) { 2 | var source = whichpic.getAttribute("href"); 3 | var placeholder = document.getElementById("placeholder"); 4 | placeholder.setAttribute("src",source); 5 | } -------------------------------------------------------------------------------- /chapter07/05/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var info = "nodeName: "; 4 | info+= para.nodeName; 5 | info+= " nodeType: "; 6 | info+= para.nodeType; 7 | alert(info); 8 | } 9 | -------------------------------------------------------------------------------- /chapter07/07/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var testdiv = document.getElementById("testdiv"); 4 | testdiv.appendChild(para); 5 | var txt = document.createTextNode("Hello world"); 6 | para.appendChild(txt); 7 | } 8 | -------------------------------------------------------------------------------- /chapter07/08/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var txt = document.createTextNode("Hello world"); 4 | para.appendChild(txt); 5 | var testdiv = document.getElementById("testdiv"); 6 | testdiv.appendChild(para); 7 | } 8 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | For an index of all the code samples, double click on index.html. 2 | 3 | To view the markup and JavaScript, navigate to the relevant folder and open up the .html and .js files in a text editor. 4 | 5 | Don't forget to visit the website of the book: http://domscripting.com/ -------------------------------------------------------------------------------- /chapter09/story/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter10/message/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter08/accesskeys/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter08/citations/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter09/itinerary/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter10/slideshow/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter10/slideshow2/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter08/abbreviations/scripts/addLoadEvent.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /chapter10/slideshow2/scripts/insertAfter.js: -------------------------------------------------------------------------------- 1 | function insertAfter(newElement,targetElement) { 2 | var parent = targetElement.parentNode; 3 | if (parent.lastChild == targetElement) { 4 | parent.appendChild(newElement); 5 | } else { 6 | parent.insertBefore(newElement,targetElement.nextSibling); 7 | } 8 | } -------------------------------------------------------------------------------- /chapter07/04/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/05/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/06/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/07/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/08/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/09/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/10/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |
12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/01/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test 6 | 7 | 8 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /chapter07/03/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Testing 6 | 7 | 9 | 10 |
11 |

This is my content.

12 |
13 | 14 | 15 | -------------------------------------------------------------------------------- /chapter04/image_gallery/03/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function showPic(whichpic) { 2 | var source = whichpic.getAttribute("href"); 3 | var placeholder = document.getElementById("placeholder"); 4 | placeholder.setAttribute("src",source); 5 | var text = whichpic.getAttribute("title"); 6 | var description = document.getElementById("description"); 7 | description.firstChild.nodeValue = text; 8 | } -------------------------------------------------------------------------------- /chapter04/image_gallery/04/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function showPic(whichpic) { 2 | var source = whichpic.getAttribute("href"); 3 | var placeholder = document.getElementById("placeholder"); 4 | placeholder.setAttribute("src",source); 5 | var text = whichpic.getAttribute("title"); 6 | var description = document.getElementById("description"); 7 | description.firstChild.nodeValue = text; 8 | } -------------------------------------------------------------------------------- /chapter07/02/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Test 6 | 8 | 9 | 10 | 13 | 14 | -------------------------------------------------------------------------------- /chapter12/domsters/scripts/ajax.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | function regen() { 6 | // home 7 | prepareSlideshow(); 8 | // about 9 | prepareInternalnav(); 10 | // photos 11 | preparePlaceholder(); 12 | prepareGallery(); 13 | // live 14 | stripeTables(); 15 | highlightRows(); 16 | displayAbbreviations(); 17 | // contact 18 | focusLabels(); 19 | prepareForms(); 20 | } 21 | 22 | 23 | -------------------------------------------------------------------------------- /chapter11/2. canvas grayscale image/grayscale.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Grayscale Canvas Example 6 | 7 | 8 | 9 | My Avatar 10 | 11 | 12 | -------------------------------------------------------------------------------- /chapter11/1. canvas simple/canvas.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Canvas 6 | 12 | 13 | 14 | 15 | 16 |

Powered By HTML5 <canvas>

17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /chapter09/itinerary/scripts/highlightRows.js: -------------------------------------------------------------------------------- 1 | function highlightRows() { 2 | if(!document.getElementsByTagName) return false; 3 | var rows = document.getElementsByTagName("tr"); 4 | for (var i=0; i 2 | 3 | 4 | 5 | Message 6 | 7 | 8 | 9 | 10 | 11 |

Whee!

12 |

Whoa!

13 | 14 | -------------------------------------------------------------------------------- /chapter07/09/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var txt1 = document.createTextNode("I inserted "); 4 | para.appendChild(txt1); 5 | var emphasis = document.createElement("em"); 6 | var txt2 = document.createTextNode("this"); 7 | emphasis.appendChild(txt2); 8 | para.appendChild(emphasis); 9 | var txt3 = document.createTextNode(" content."); 10 | para.appendChild(txt3); 11 | var testdiv = document.getElementById("testdiv"); 12 | testdiv.appendChild(para); 13 | } 14 | -------------------------------------------------------------------------------- /chapter07/10/example.js: -------------------------------------------------------------------------------- 1 | window.onload = function() { 2 | var para = document.createElement("p"); 3 | var txt1 = document.createTextNode("I inserted "); 4 | var emphasis = document.createElement("em"); 5 | var txt2 = document.createTextNode("this"); 6 | var txt3 = document.createTextNode(" content."); 7 | para.appendChild(txt1); 8 | emphasis.appendChild(txt2); 9 | para.appendChild(emphasis); 10 | para.appendChild(txt3); 11 | var testdiv = document.getElementById("testdiv"); 12 | testdiv.appendChild(para); 13 | } 14 | -------------------------------------------------------------------------------- /chapter04/image_gallery/04/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | img { 26 | display:block; 27 | clear: both; 28 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Apress Source Code 2 | 3 | This repository accompanies [*DOM Scripting*](http://www.apress.com/9781430233893) by Jeremy Keith and Jeffrey Sambells (Apress, 2010). 4 | 5 | ![Cover image](9781430233893.jpg) 6 | 7 | Download the files as a zip using the green button, or clone the repository to your machine using Git. 8 | 9 | ## Releases 10 | 11 | Release v1.0 corresponds to the code in the published book, without corrections or updates. 12 | 13 | ## Contributions 14 | 15 | See the file Contributing.md for more information on how you can contribute to this repository. 16 | -------------------------------------------------------------------------------- /chapter09/itinerary/styles/format.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",sans-serif; 3 | background-color: #fff; 4 | color: #000; 5 | } 6 | table { 7 | margin: auto; 8 | border: 1px solid #699; 9 | } 10 | caption { 11 | margin: auto; 12 | padding: .2em; 13 | font-size: 1.2em; 14 | font-weight: bold; 15 | } 16 | th { 17 | font-weight: normal; 18 | font-style: italic; 19 | text-align: left; 20 | border: 1px dotted #699; 21 | background-color: #9cc; 22 | color: #000; 23 | } 24 | th,td { 25 | width: 10em; 26 | padding: .5em; 27 | } 28 | .odd { 29 | background-color: #ffc; 30 | } -------------------------------------------------------------------------------- /chapter09/example.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Example 6 | 14 | 15 | 16 |

17 | An example of a paragraph 18 |

19 | 20 | -------------------------------------------------------------------------------- /chapter11/3. video custom controls/styles/player.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 10px; 3 | } 4 | 5 | .video-wrapper { 6 | overflow: hidden; 7 | } 8 | 9 | .video-wrapper .controls { 10 | position: absolute; 11 | height:30px; 12 | width:30px; 13 | margin: auto; 14 | background: rgba(0,0,0,0.5); 15 | } 16 | 17 | .video-wrapper button { 18 | display: block; 19 | width: 100%; 20 | height: 100%; 21 | border: 0; 22 | cursor: pointer; 23 | font-size: 17px; 24 | font-family: arial; 25 | color: #fff; 26 | background: transparent; 27 | } 28 | 29 | .video-wrapper button[paused] { 30 | font-size: 12px; 31 | } 32 | -------------------------------------------------------------------------------- /chapter06/image_gallery/03/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | #imagegallery { 26 | list-style: none; 27 | } 28 | 29 | #imagegallery li { 30 | display: inline; 31 | } 32 | 33 | #imagegallery li a img { 34 | border: 0; 35 | } -------------------------------------------------------------------------------- /chapter07/image_gallery/01/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | #imagegallery { 26 | list-style: none; 27 | } 28 | 29 | #imagegallery li { 30 | display: inline; 31 | } 32 | 33 | #imagegallery li a img { 34 | border: 0; 35 | } -------------------------------------------------------------------------------- /chapter07/image_gallery/02/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | #imagegallery { 26 | list-style: none; 27 | } 28 | 29 | #imagegallery li { 30 | display: inline; 31 | } 32 | 33 | #imagegallery li a img { 34 | border: 0; 35 | } -------------------------------------------------------------------------------- /chapter07/image_gallery/03/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | #imagegallery { 26 | list-style: none; 27 | } 28 | 29 | #imagegallery li { 30 | display: inline; 31 | } 32 | 33 | #imagegallery li a img { 34 | border: 0; 35 | } -------------------------------------------------------------------------------- /chapter07/image_gallery/04/styles/layout.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: "Helvetica","Arial",serif; 3 | color: #333; 4 | background-color: #ccc; 5 | margin: 1em 10%; 6 | } 7 | h1 { 8 | color: #333; 9 | background-color: transparent; 10 | } 11 | a { 12 | color: #c60; 13 | background-color: transparent; 14 | font-weight: bold; 15 | text-decoration: none; 16 | } 17 | ul { 18 | padding: 0; 19 | } 20 | li { 21 | float: left; 22 | padding: 1em; 23 | list-style: none; 24 | } 25 | #imagegallery { 26 | list-style: none; 27 | } 28 | 29 | #imagegallery li { 30 | display: inline; 31 | } 32 | 33 | #imagegallery li a img { 34 | border: 0; 35 | } -------------------------------------------------------------------------------- /chapter10/message/scripts/positionMessage.js: -------------------------------------------------------------------------------- 1 | function positionMessage() { 2 | if (!document.getElementById) return false; 3 | if (!document.getElementById("message")) return false; 4 | var elem = document.getElementById("message"); 5 | elem.style.position = "absolute"; 6 | elem.style.left = "50px"; 7 | elem.style.top = "100px"; 8 | moveElement("message",125,25,20); 9 | if (!document.getElementById("message2")) return false; 10 | var elem = document.getElementById("message2"); 11 | elem.style.position = "absolute"; 12 | elem.style.left = "50px"; 13 | elem.style.top = "50px"; 14 | moveElement("message2",125,75,20); 15 | } 16 | addLoadEvent(positionMessage); -------------------------------------------------------------------------------- /styles/colour.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #123; 3 | background: #fff url(../images/background.gif) top left repeat-x; 4 | } 5 | a:link { 6 | color: #567; 7 | border-color: #567; 8 | background-color: transparent; 9 | } 10 | a:visited { 11 | color: #456; 12 | border-color: #456; 13 | background-color: transparent; 14 | } 15 | a:hover { 16 | color: #966; 17 | border-color: #966; 18 | background-color: transparent; 19 | } 20 | a:active { 21 | color: #876; 22 | border-color: #876; 23 | background-color: transparent; 24 | } 25 | h1 { 26 | color: #633; 27 | border-bottom-color: #cba; 28 | } 29 | 30 | #container { 31 | background-color: #fff; 32 | border-color: #bcc; 33 | } -------------------------------------------------------------------------------- /chapter04/image_gallery/01/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 |

Snapshots

9 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing to Apress Source Code 2 | 3 | Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers. 4 | 5 | ## How to Contribute 6 | 7 | 1. Make sure you have a GitHub account. 8 | 2. Fork the repository for the relevant book. 9 | 3. Create a new branch on which to make your change, e.g. 10 | `git checkout -b my_code_contribution` 11 | 4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted. 12 | 5. Submit a pull request. 13 | 14 | Thank you for your contribution! -------------------------------------------------------------------------------- /chapter09/story/scripts/styleHeaderSiblings.js: -------------------------------------------------------------------------------- 1 | function styleHeaderSiblings() { 2 | if (!document.getElementsByTagName) return false; 3 | var headers = document.getElementsByTagName("h1"); 4 | for (var i=0; i 2 | 3 | 4 | 5 | Example 6 | 25 | 26 | 27 | Example 28 | 29 | 30 | -------------------------------------------------------------------------------- /chapter09/itinerary/scripts/stripeTables.js: -------------------------------------------------------------------------------- 1 | function stripeTables() { 2 | if (!document.getElementsByTagName) return false; 3 | var tables = document.getElementsByTagName("table"); 4 | for (var i=0; i final_x) { 14 | xpos--; 15 | } 16 | if (ypos < final_y) { 17 | ypos++; 18 | } 19 | if (ypos > final_y) { 20 | ypos--; 21 | } 22 | elem.style.left = xpos + "px"; 23 | elem.style.top = ypos + "px"; 24 | var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; 25 | movement = setTimeout(repeat,interval); 26 | } -------------------------------------------------------------------------------- /chapter09/story/story.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Man bites dog 7 | 8 | 9 | 10 | 11 | 12 |

Hold the front page

13 |

This first paragraph leads you in.

14 |

Now you get the nitty-gritty of the story.

15 |

The most important information is delivered first.

16 |

Extra! Extra!

17 |

Further developments are unfolding.

18 |

You can read all about it here.

19 | 20 | -------------------------------------------------------------------------------- /chapter06/image_gallery/01/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 |

Snapshots

10 | 24 | my image gallery 25 |

Choose an image.

26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter10/slideshow/scripts/moveElement.js: -------------------------------------------------------------------------------- 1 | function moveElement(elementID,final_x,final_y,interval) { 2 | if (!document.getElementById) return false; 3 | if (!document.getElementById(elementID)) return false; 4 | var elem = document.getElementById(elementID); 5 | if (elem.movement) { 6 | clearTimeout(elem.movement); 7 | } 8 | var xpos = parseInt(elem.style.left); 9 | var ypos = parseInt(elem.style.top); 10 | 11 | if (xpos == final_x && ypos == final_y) { 12 | return true; 13 | } 14 | if (xpos < final_x) { 15 | xpos++; 16 | } 17 | if (xpos > final_x) { 18 | xpos--; 19 | } 20 | if (ypos < final_y) { 21 | ypos++; 22 | } 23 | if (ypos > final_y) { 24 | ypos--; 25 | } 26 | elem.style.left = xpos + "px"; 27 | elem.style.top = ypos + "px"; 28 | var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; 29 | elem.movement = setTimeout(repeat,interval); 30 | } -------------------------------------------------------------------------------- /chapter12/domsters/submit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jay Skript And The Domsters: Contact the band 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 |
23 |

Thanks!

24 |

Thanks for contacting us. We'll get back to you as soon as we can.

25 |
26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter11/3. video custom controls/player.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | My Video 6 | 7 | 8 | 9 |
10 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /chapter04/image_gallery/02/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 |

Snapshots

10 | 24 | my image gallery 25 | 26 | 27 | -------------------------------------------------------------------------------- /chapter10/slideshow2/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web Design 6 | 9 | 11 | 13 | 15 | 17 | 18 | 19 |

Web Design

20 |

These are the things you should know.

21 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /chapter04/image_gallery/03/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 |

Snapshots

10 | 24 | my image gallery 25 |

Choose an image.

26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter10/slideshow/list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Web Design 6 | 9 | 11 | 13 | 15 | 16 | 17 |

Web Design

18 |

These are the things you should know.

19 | 30 |
31 | building blocks of web design 32 |
33 | 34 | 35 | -------------------------------------------------------------------------------- /chapter12/domsters/styles/typography.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-size: 76%; 3 | font-family: "Helvetica","Arial",sans-serif; 4 | } 5 | body * { 6 | font-size: 1em; 7 | } 8 | a { 9 | font-weight: bold; 10 | text-decoration: none; 11 | } 12 | header nav { 13 | font-family: "Lucida Grande","Helvetica","Arial",sans-serif; 14 | } 15 | header nav a { 16 | text-decoration: none; 17 | font-weight: bold; 18 | } 19 | article { 20 | line-height: 1.8em; 21 | } 22 | article p { 23 | margin: 1em 0; 24 | } 25 | h1 { 26 | font-family: "Georgia","Times New Roman",sans-serif; 27 | font: 2.4em normal; 28 | } 29 | h2 { 30 | font-family: "Georgia","Times New Roman",sans-serif; 31 | font: 1.8em normal; 32 | margin-top: 1em; 33 | } 34 | h3 { 35 | font-family: "Georgia","Times New Roman",sans-serif; 36 | font: 1.4em normal; 37 | margin-top: 1em; 38 | } 39 | #imagegallery li { 40 | list-style-type: none; 41 | } 42 | textarea { 43 | font-family: "Helvetica","Arial",sans-serif; 44 | } 45 | 46 | dt { 47 | margin-right: 1em; 48 | } 49 | dd { 50 | margin-right: 3em; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /chapter10/slideshow/scripts/prepareSlideshow.js: -------------------------------------------------------------------------------- 1 | function prepareSlideshow() { 2 | // Make sure the browser understands the DOM methods 3 | if (!document.getElementsByTagName) return false; 4 | if (!document.getElementById) return false; 5 | // Make sure the elements exist 6 | if (!document.getElementById("linklist")) return false; 7 | if (!document.getElementById("preview")) return false; 8 | // Apply styles to the preview image 9 | var preview = document.getElementById("preview"); 10 | preview.style.position = "absolute"; 11 | preview.style.left = "0px"; 12 | preview.style.top = "0px"; 13 | // Get all the links in the list 14 | var list = document.getElementById("linklist"); 15 | var links = list.getElementsByTagName("a"); 16 | // Attach the animation behavior to the mouseover event 17 | links[0].onmouseover = function() { 18 | moveElement("preview",-100,0,10); 19 | } 20 | links[1].onmouseover = function() { 21 | moveElement("preview",-200,0,10); 22 | } 23 | links[2].onmouseover = function() { 24 | moveElement("preview",-300,0,10); 25 | } 26 | } 27 | addLoadEvent(prepareSlideshow); -------------------------------------------------------------------------------- /chapter04/image_gallery/04/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 25 | my image gallery 26 |

Choose an image.

27 | 28 | 29 | -------------------------------------------------------------------------------- /chapter03/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Shopping list 6 | 27 | 28 | 29 |

What to buy

30 |

Don't forget to buy this stuff.

31 |

This is just a test

32 |
    33 |
  • A tin of beans
  • 34 |
  • Cheese
  • 35 |
  • Milk
  • 36 |
37 | 46 | 47 | -------------------------------------------------------------------------------- /chapter07/image_gallery/02/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /chapter07/image_gallery/03/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /chapter12/domsters/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jay Skript And The Domsters 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /chapter07/image_gallery/04/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /chapter09/itinerary/itinerary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cities 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
Itinerary
WhenWhere
June 9thPortland, OR
June 10thSeattle, WA
June 12thSacramento, CA
36 | 37 | -------------------------------------------------------------------------------- /chapter11/4. forms/examples.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Text and Email Input Types 6 | 7 | 8 | 9 |
10 |

11 |

12 | 13 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /chapter10/slideshow2/scripts/prepareSlideshow.js: -------------------------------------------------------------------------------- 1 | function prepareSlideshow() { 2 | // Make sure the browser understands the DOM methods 3 | if (!document.getElementsByTagName) return false; 4 | if (!document.getElementById) return false; 5 | // Make sure the elements exist 6 | if (!document.getElementById("linklist")) return false; 7 | var slideshow = document.createElement("div"); 8 | slideshow.setAttribute("id","slideshow"); 9 | var preview = document.createElement("img"); 10 | preview.setAttribute("src","topics.gif"); 11 | preview.setAttribute("alt","building blocks of web design"); 12 | preview.setAttribute("id","preview"); 13 | slideshow.appendChild(preview); 14 | var list = document.getElementById("linklist"); 15 | insertAfter(slideshow,list); 16 | // Get all the links in the list 17 | var links = list.getElementsByTagName("a"); 18 | // Attach the animation behavior to the mouseover event 19 | links[0].onmouseover = function() { 20 | moveElement("preview",-100,0,10); 21 | } 22 | links[1].onmouseover = function() { 23 | moveElement("preview",-200,0,10); 24 | } 25 | links[2].onmouseover = function() { 26 | moveElement("preview",-300,0,10); 27 | } 28 | } 29 | addLoadEvent(prepareSlideshow); -------------------------------------------------------------------------------- /chapter08/abbreviations/explanation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Explaining the Document Object Model 6 | 7 | 8 | 9 | 10 | 11 |

What is the Document Object Model?

12 |

13 | The W3C defines 14 | the DOM as: 15 |

16 |
17 |

18 | A platform- and language-neutral interface that will allow programs 19 | and scripts to dynamically access and update the 20 | content, structure and style of documents. 21 |

22 |
23 |

24 | It is an API 25 | that can be used to navigate 26 | HTML and XML 27 | documents. 28 |

29 | 30 | -------------------------------------------------------------------------------- /chapter06/image_gallery/02/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | my image gallery 34 |

Choose an image.

35 | 36 | 37 | -------------------------------------------------------------------------------- /chapter06/image_gallery/03/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | my image gallery 34 |

Choose an image.

35 | 36 | 37 | -------------------------------------------------------------------------------- /chapter07/image_gallery/01/gallery.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Image Gallery 6 | 7 | 8 | 9 | 10 |

Snapshots

11 | 33 | my image gallery 34 |

Choose an image.

35 | 36 | 37 | -------------------------------------------------------------------------------- /chapter10/slideshow2/scripts/moveElement.js: -------------------------------------------------------------------------------- 1 | function moveElement(elementID,final_x,final_y,interval) { 2 | if (!document.getElementById) return false; 3 | if (!document.getElementById(elementID)) return false; 4 | var elem = document.getElementById(elementID); 5 | if (elem.movement) { 6 | clearTimeout(elem.movement); 7 | } 8 | if (!elem.style.left) { 9 | elem.style.left = "0px"; 10 | } 11 | if (!elem.style.top) { 12 | elem.style.top = "0px"; 13 | } 14 | var xpos = parseInt(elem.style.left); 15 | var ypos = parseInt(elem.style.top); 16 | if (xpos == final_x && ypos == final_y) { 17 | return true; 18 | } 19 | if (xpos < final_x) { 20 | var dist = Math.ceil((final_x - xpos)/10); 21 | xpos = xpos + dist; 22 | } 23 | if (xpos > final_x) { 24 | var dist = Math.ceil((xpos - final_x)/10); 25 | xpos = xpos - dist; 26 | } 27 | if (ypos < final_y) { 28 | var dist = Math.ceil((final_y - ypos)/10); 29 | ypos = ypos + dist; 30 | } 31 | if (ypos > final_y) { 32 | var dist = Math.ceil((ypos - final_y)/10); 33 | ypos = ypos - dist; 34 | } 35 | elem.style.left = xpos + "px"; 36 | elem.style.top = ypos + "px"; 37 | var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; 38 | elem.movement = setTimeout(repeat,interval); 39 | } -------------------------------------------------------------------------------- /chapter08/accesskeys/scripts/displayCitations.js: -------------------------------------------------------------------------------- 1 | function displayCitations() { 2 | if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) return false; 3 | // get all the blockquotes 4 | var quotes = document.getElementsByTagName("blockquote"); 5 | // loop through all the blockquotes 6 | for (var i=0; i 2 | 3 | 4 | 5 | Explaining the Document Object Model 6 | 7 | 8 | 9 | 10 | 11 | 12 |

What is the Document Object Model?

13 |

14 | The W3C defines 15 | the DOM as: 16 |

17 |
18 |

19 | A platform- and language-neutral interface that will allow programs 20 | and scripts to dynamically access and update the 21 | content, structure and style of documents. 22 |

23 |
24 |

25 | It is an API 26 | that can be used to navigate 27 | HTML and XML 28 | documents. 29 |

30 | 31 | -------------------------------------------------------------------------------- /chapter11/2. canvas grayscale image/scripts/grayscale.js: -------------------------------------------------------------------------------- 1 | function convertToGS(img) { 2 | // For good measure return if canvas isn't supported. 3 | if (!Modernizr.canvas) return; 4 | 5 | // Store the original color version. 6 | img.color = img.src; 7 | 8 | // Create a grayscale version. 9 | img.grayscale = createGSCanvas(img); 10 | 11 | // Swap the images on mouseover/out 12 | img.onmouseover = function() { 13 | this.src = this.color; 14 | } 15 | img.onmouseout = function() { 16 | this.src = this.grayscale; 17 | } 18 | 19 | img.onmouseout(); 20 | } 21 | 22 | function createGSCanvas(img) { 23 | 24 | var canvas=document.createElement("canvas"); 25 | canvas.width=img.width; 26 | canvas.height=img.height; 27 | var ctx=canvas.getContext("2d"); 28 | ctx.drawImage(img,0,0); 29 | 30 | // Note: getImageData will only work for images 31 | // on the same domain as the script. 32 | var c = ctx.getImageData(0, 0, img.width, img.height); 33 | for (i=0; i 2 | 3 | 4 | 5 | Jay Skript And The Domsters: Contact the band 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 |
23 |

Contact the band

24 |
25 |
26 |

27 | 28 | 29 |

30 |

31 | 32 | 33 |

34 |

35 | 36 | 37 |

38 | 39 |
40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /chapter11/3. video custom controls/scripts/player.js: -------------------------------------------------------------------------------- 1 | (function() { 2 | 3 | function createVideoControls() { 4 | var vids = document.getElementsByTagName('video'); 5 | for (var i = 0 ; i < vids.length ; i++) { 6 | addControls( vids[i] ); 7 | } 8 | } 9 | 10 | function addControls( vid ) { 11 | 12 | vid.removeAttribute('controls'); 13 | 14 | 15 | vid.height = vid.videoHeight; 16 | vid.width = vid.videoWidth; 17 | vid.parentNode.style.height = vid.videoHeight + 'px'; 18 | vid.parentNode.style.width = vid.videoWidth + 'px'; 19 | 20 | var controls = document.createElement('div'); 21 | controls.setAttribute('class','controls'); 22 | 23 | var play = document.createElement('button'); 24 | play.setAttribute('title','Play'); 25 | play.innerHTML = '►'; 26 | 27 | controls.appendChild(play); 28 | 29 | vid.parentNode.insertBefore(controls, vid); 30 | 31 | play.onclick = function () { 32 | if (vid.ended) { 33 | vid.currentTime = 0; 34 | } 35 | if (vid.paused) { 36 | vid.play(); 37 | } else { 38 | vid.pause(); 39 | } 40 | }; 41 | 42 | vid.addEventListener('play', function () { 43 | play.innerHTML = '▐▐'; 44 | play.setAttribute('paused', true); 45 | }, false); 46 | 47 | vid.addEventListener('pause', function () { 48 | play.removeAttribute('paused'); 49 | play.innerHTML = '►'; 50 | }, false); 51 | 52 | vid.addEventListener('ended', function () { 53 | vid.pause(); 54 | }, false); 55 | } 56 | 57 | window.onload = function() { 58 | createVideoControls(); 59 | } 60 | 61 | })() 62 | -------------------------------------------------------------------------------- /chapter12/domsters/template.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jay Skript And The Domsters 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 |
23 |

Lorem Ipsum Dolor

24 |

Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 25 | Nullam iaculis vestibulum turpis. Pellentesque mattis rutrum 26 | nibh. Quisque orci orci, euismod sit amet, sollicitudin et, 27 | ullamcorper at, lorem. 28 | Pellentesque habitant morbi tristique senectus et netus 29 | et malesuada fames ac turpis egestas. 30 | Ut lectus. Mauris eu sapien non enim dapibus imperdiet. 31 | Sed eu mauris sed pede mollis commodo. 32 | Fusce eget est. Sed ullamcorper enim nec est. 33 | Cras dui felis, porta vitae, faucibus laoreet, sollicitudin eget, 34 | enim. Nulla auctor. Fusce interdum diam ac eros. 35 | Mauris egestas. Fusce in elit et sem aliquet pretium. 36 | Donec nunc erat, sodales ac, facilisis a, molestie eu, massa. 37 | Aenean nec justo eu neque malesuada aliquet.

38 |
39 | 40 | 41 | -------------------------------------------------------------------------------- /chapter10/test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Animation 6 | 56 | 57 | 58 |

Whee!

59 | 60 | 61 | -------------------------------------------------------------------------------- /chapter08/accesskeys/explanation.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Explaining the Document Object Model 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 18 |

What is the Document Object Model?

19 |

20 | The W3C defines 21 | the DOM as: 22 |

23 |
24 |

25 | A platform- and language-neutral interface that will allow programs 26 | and scripts to dynamically access and update the 27 | content, structure and style of documents. 28 |

29 |
30 |

31 | It is an API 32 | that can be used to navigate 33 | HTML and XML 34 | documents. 35 |

36 | 37 | -------------------------------------------------------------------------------- /chapter08/accesskeys/scripts/displayAccesskeys.js: -------------------------------------------------------------------------------- 1 | function displayAccesskeys() { 2 | if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) return false; 3 | // get all the links in the document 4 | var links = document.getElementsByTagName("a"); 5 | // create an array to store the accesskeys 6 | var akeys = new Array(); 7 | // loop through the links 8 | for (var i=0; i 2 | 3 | 4 | 5 | Jay Skript And The Domsters: Photos 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /chapter12/domsters/styles/color.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #fb5; 3 | background-color: #334; 4 | } 5 | a:link { 6 | color: #445; 7 | background-color: #eb6; 8 | } 9 | a:visited { 10 | color: #345; 11 | background-color: #eb6; 12 | } 13 | a:hover { 14 | color: #667; 15 | background-color: #fb5; 16 | } 17 | a:active { 18 | color: #778; 19 | background-color: #ec8; 20 | } 21 | header { 22 | color: #ec8; 23 | background-color: #334; 24 | border-color: #667; 25 | } 26 | header nav { 27 | color: #455; 28 | background-color: #789; 29 | border-color: #667; 30 | } 31 | article { 32 | color: #223; 33 | background-color: #edc; 34 | border-color: #667; 35 | } 36 | header nav ul { 37 | border-color: #99a; 38 | } 39 | header nav a:link,header nav a:visited { 40 | color: #eef; 41 | background-color: transparent; 42 | border-color: #99a; 43 | } 44 | header nav a:hover { 45 | color: #445; 46 | background-color: #eb6; 47 | } 48 | header nav a:active { 49 | color: #667; 50 | background-color: #ec8; 51 | } 52 | article img { 53 | border-color: #ba9; 54 | outline-color: #dcb; 55 | } 56 | #imagegallery a { 57 | background-color: transparent; 58 | } 59 | 60 | 61 | 62 | 63 | 64 | header nav a.here:link, 65 | header nav a.here:visited, 66 | header nav a.here:hover, 67 | header nav a.here:active { 68 | color: #eef; 69 | background-color: #799; 70 | } 71 | 72 | 73 | 74 | th { 75 | color: #edc; 76 | background-color: #455; 77 | } 78 | tr td { 79 | color: #223; 80 | background-color: #eb6; 81 | } 82 | tr.odd td { 83 | color: #223; 84 | background-color: #ec8; 85 | } 86 | tr.highlight td { 87 | color: #223; 88 | background-color: #cba; 89 | } 90 | 91 | 92 | 93 | 94 | 95 | input.placeholder { 96 | color: grey; 97 | } 98 | -------------------------------------------------------------------------------- /chapter12/domsters/live.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jay Skript And The Domsters: Tour dates 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 |
23 |

Tour dates

24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |
DateCityVenue
June 9thPortland, ORCrystal Ballroom
June 10thSeattle, WACrocodile Cafe
June 12thSacramento, CATorch Club
June 17thAustin, TXSpeakeasy
55 |
56 | 57 | 58 | -------------------------------------------------------------------------------- /chapter08/abbreviations/scripts/displayAbbreviations.js: -------------------------------------------------------------------------------- 1 | function displayAbbreviations() { 2 | if (!document.getElementsByTagName || !document.createElement || !document.createTextNode) return false; 3 | // get all the abbreviations 4 | var abbreviations = document.getElementsByTagName("abbr"); 5 | if (abbreviations.length < 1) return false; 6 | var defs = new Array(); 7 | // loop through the abbreviations 8 | for (var i=0; i 2 | 3 | 4 | 6 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 52 | 53 | -------------------------------------------------------------------------------- /chapter12/domsters/about.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Jay Skript And The Domsters: About the band 6 | 7 | 8 | 9 | 10 |
11 | Jay Skript and the Domsters 12 | 21 |
22 |
23 |

About the band

24 | 30 |
31 |

Jay Skript

32 |

Jay Skript is going to rock your world!

33 |

Together with his compatriots The Domsters, 34 | Jay is set for world domination. Just you wait and see.

35 |

Jay Skript has been on the scene since the mid nineties. 36 | His talent hasn't always been recognized or fully appreciated. 37 | In the early days, he was often unfavorably compared to bigger, 38 | similarly-named artists. That's all in the past now.

39 |
40 |
41 |

The Domsters

42 |

The Domsters have been around, in one form or another, 43 | for almost as long. It's only in the past few years that The Domsters 44 | have settled down to their current, stable line-up. 45 | Now they're a rock-solid bunch: methodical and dependable.

46 |
47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /chapter07/image_gallery/03/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function showPic(whichpic) { 2 | if (!document.getElementById("placeholder")) return true; 3 | var source = whichpic.getAttribute("href"); 4 | var placeholder = document.getElementById("placeholder"); 5 | placeholder.setAttribute("src",source); 6 | if (!document.getElementById("description")) return false; 7 | if (whichpic.getAttribute("title")) { 8 | var text = whichpic.getAttribute("title"); 9 | } else { 10 | var text = ""; 11 | } 12 | var description = document.getElementById("description"); 13 | if (description.firstChild.nodeType == 3) { 14 | description.firstChild.nodeValue = text; 15 | } 16 | return false; 17 | } 18 | 19 | function prepareGallery() { 20 | if (!document.getElementsByTagName) return false; 21 | if (!document.getElementById) return false; 22 | if (!document.getElementById("imagegallery")) return false; 23 | var gallery = document.getElementById("imagegallery"); 24 | var links = gallery.getElementsByTagName("a"); 25 | for ( var i=0; i < links.length; i++) { 26 | links[i].onclick = function() { 27 | return showPic(this); 28 | } 29 | links[i].onkeypress = links[i].onclick; 30 | } 31 | } 32 | 33 | function addLoadEvent(func) { 34 | var oldonload = window.onload; 35 | if (typeof window.onload != 'function') { 36 | window.onload = func; 37 | } else { 38 | window.onload = function() { 39 | oldonload(); 40 | func(); 41 | } 42 | } 43 | } 44 | 45 | function preparePlaceholder() { 46 | if (!document.createElement) return false; 47 | if (!document.createTextNode) return false; 48 | var placeholder = document.createElement("img"); 49 | placeholder.setAttribute("id","placeholder"); 50 | placeholder.setAttribute("src","images/placeholder.gif"); 51 | placeholder.setAttribute("alt","my image gallery"); 52 | var description = document.createElement("p"); 53 | description.setAttribute("id","description"); 54 | var desctext = document.createTextNode("Choose an image"); 55 | description.appendChild(desctext); 56 | var gallery = document.getElementById("imagegallery"); 57 | gallery.parentNode.insertBefore(placeholder,gallery); 58 | gallery.parentNode.insertBefore(description,gallery); 59 | } 60 | 61 | addLoadEvent(preparePlaceholder); 62 | addLoadEvent(prepareGallery); -------------------------------------------------------------------------------- /chapter07/image_gallery/02/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function showPic(whichpic) { 2 | if (!document.getElementById("placeholder")) return true; 3 | var source = whichpic.getAttribute("href"); 4 | var placeholder = document.getElementById("placeholder"); 5 | placeholder.setAttribute("src",source); 6 | if (!document.getElementById("description")) return false; 7 | if (whichpic.getAttribute("title")) { 8 | var text = whichpic.getAttribute("title"); 9 | } else { 10 | var text = ""; 11 | } 12 | var description = document.getElementById("description"); 13 | if (description.firstChild.nodeType == 3) { 14 | description.firstChild.nodeValue = text; 15 | } 16 | return false; 17 | } 18 | 19 | function prepareGallery() { 20 | if (!document.getElementsByTagName) return false; 21 | if (!document.getElementById) return false; 22 | if (!document.getElementById("imagegallery")) return false; 23 | var gallery = document.getElementById("imagegallery"); 24 | var links = gallery.getElementsByTagName("a"); 25 | for ( var i=0; i < links.length; i++) { 26 | links[i].onclick = function() { 27 | return showPic(this); 28 | } 29 | links[i].onkeypress = links[i].onclick; 30 | } 31 | } 32 | 33 | function addLoadEvent(func) { 34 | var oldonload = window.onload; 35 | if (typeof window.onload != 'function') { 36 | window.onload = func; 37 | } else { 38 | window.onload = function() { 39 | oldonload(); 40 | func(); 41 | } 42 | } 43 | } 44 | 45 | function preparePlaceholder() { 46 | if (!document.createElement) return false; 47 | if (!document.createTextNode) return false; 48 | var placeholder = document.createElement("img"); 49 | placeholder.setAttribute("id","placeholder"); 50 | placeholder.setAttribute("src","images/placeholder.gif"); 51 | placeholder.setAttribute("alt","my image gallery"); 52 | var description = document.createElement("p"); 53 | description.setAttribute("id","description"); 54 | var desctext = document.createTextNode("Choose an image"); 55 | description.appendChild(desctext); 56 | var gallery = document.getElementById("imagegallery"); 57 | document.getElementsByTagName("body")[0].appendChild(placeholder); 58 | document.getElementsByTagName("body")[0].appendChild(description); 59 | } 60 | 61 | addLoadEvent(preparePlaceholder); 62 | addLoadEvent(prepareGallery); -------------------------------------------------------------------------------- /chapter07/image_gallery/04/scripts/showPic.js: -------------------------------------------------------------------------------- 1 | function addLoadEvent(func) { 2 | var oldonload = window.onload; 3 | if (typeof window.onload != 'function') { 4 | window.onload = func; 5 | } else { 6 | window.onload = function() { 7 | oldonload(); 8 | func(); 9 | } 10 | } 11 | } 12 | 13 | function insertAfter(newElement,targetElement) { 14 | var parent = targetElement.parentNode; 15 | if (parent.lastChild == targetElement) { 16 | parent.appendChild(newElement); 17 | } else { 18 | parent.insertBefore(newElement,targetElement.nextSibling); 19 | } 20 | } 21 | 22 | function preparePlaceholder() { 23 | if (!document.createElement) return false; 24 | if (!document.createTextNode) return false; 25 | if (!document.getElementById) return false; 26 | if (!document.getElementById("imagegallery")) return false; 27 | var placeholder = document.createElement("img"); 28 | placeholder.setAttribute("id","placeholder"); 29 | placeholder.setAttribute("src","images/placeholder.gif"); 30 | placeholder.setAttribute("alt","my image gallery"); 31 | var description = document.createElement("p"); 32 | description.setAttribute("id","description"); 33 | var desctext = document.createTextNode("Choose an image"); 34 | description.appendChild(desctext); 35 | var gallery = document.getElementById("imagegallery"); 36 | insertAfter(placeholder,gallery); 37 | insertAfter(description,placeholder); 38 | } 39 | 40 | function prepareGallery() { 41 | if (!document.getElementsByTagName) return false; 42 | if (!document.getElementById) return false; 43 | if (!document.getElementById("imagegallery")) return false; 44 | var gallery = document.getElementById("imagegallery"); 45 | var links = gallery.getElementsByTagName("a"); 46 | for ( var i=0; i < links.length; i++) { 47 | links[i].onclick = function() { 48 | return showPic(this); 49 | } 50 | links[i].onkeypress = links[i].onclick; 51 | } 52 | } 53 | 54 | function showPic(whichpic) { 55 | if (!document.getElementById("placeholder")) return true; 56 | var source = whichpic.getAttribute("href"); 57 | var placeholder = document.getElementById("placeholder"); 58 | placeholder.setAttribute("src",source); 59 | if (!document.getElementById("description")) return false; 60 | if (whichpic.getAttribute("title")) { 61 | var text = whichpic.getAttribute("title"); 62 | } else { 63 | var text = ""; 64 | } 65 | var description = document.getElementById("description"); 66 | if (description.firstChild.nodeType == 3) { 67 | description.firstChild.nodeValue = text; 68 | } 69 | return false; 70 | } 71 | 72 | addLoadEvent(preparePlaceholder); 73 | addLoadEvent(prepareGallery); -------------------------------------------------------------------------------- /chapter12/domsters/styles/layout.css: -------------------------------------------------------------------------------- 1 | section, header, article, nav { 2 | display: block; 3 | } 4 | 5 | * { 6 | padding: 0; 7 | margin: 0; 8 | } 9 | 10 | body { 11 | margin: 1em 10%; 12 | background-image: url(../images/background.gif); 13 | background-attachment: fixed; 14 | background-position: top left; 15 | background-repeat: repeat-x; 16 | max-width: 80em; 17 | } 18 | header { 19 | background-image: url(../images/guitarist.gif); 20 | background-repeat: no-repeat; 21 | background-position: bottom right; 22 | border-width: .1em; 23 | border-style: solid; 24 | border-bottom-width: 0; 25 | } 26 | header nav { 27 | background-image: url(../images/header navbar.gif); 28 | background-position: bottom left; 29 | background-repeat: repeat-x; 30 | border-width: .1em; 31 | border-style: solid; 32 | border-bottom-width: 0; 33 | border-top-width: 0; 34 | padding-left: 10%; 35 | } 36 | header nav ul { 37 | width: 100%; 38 | overflow: hidden; 39 | border-left-width: .1em; 40 | border-left-style: solid; 41 | } 42 | header nav li { 43 | display: inline; 44 | } 45 | header nav li a { 46 | display: block; 47 | float: left; 48 | padding: .5em 2em; 49 | border-right: .1em solid; 50 | } 51 | article { 52 | border-width: .1em; 53 | border-style: solid; 54 | border-top-width: 0; 55 | padding: 2em 10%; 56 | line-height: 1.8em; 57 | } 58 | article img { 59 | border-width: .1em; 60 | border-style: solid; 61 | outline-width: .1em; 62 | outline-style: solid; 63 | } 64 | 65 | 66 | 67 | 68 | 69 | #about header { 70 | background-image: url(../images/lineup.gif); 71 | } 72 | #photos header { 73 | background-image: url(../images/basshead.gif); 74 | } 75 | #live header { 76 | background-image: url(../images/bassist.gif); 77 | } 78 | #contact header { 79 | background-image: url(../images/drummer.gif); 80 | } 81 | 82 | #slideshow { 83 | width: 150px; 84 | height: 150px; 85 | position: relative; 86 | overflow: hidden; 87 | } 88 | #preview { 89 | position: absolute; 90 | border-width: 0; 91 | outline-width: 0; 92 | } 93 | 94 | #frame { 95 | position: absolute; 96 | top: 0; 97 | left: 0; 98 | z-index: 99; 99 | border-width: 0; 100 | outline-width: 0; 101 | } 102 | 103 | 104 | #imagegallery li { 105 | display: inline; 106 | } 107 | 108 | 109 | td { 110 | padding: .5em 3em; 111 | } 112 | 113 | 114 | dl { 115 | overflow: hidden; 116 | } 117 | dt { 118 | float: left; 119 | } 120 | dd { 121 | float: left; 122 | } 123 | 124 | 125 | label { 126 | display: block; 127 | } 128 | fieldset { 129 | border: 0; 130 | } 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | DOM Scripting: Web Design with JavaScript and the Document Object Model 6 | 7 | 8 | 9 | 10 |
11 | 12 | 16 | 17 |

Code Examples

18 | 19 |
    20 |
  1. A brief history of JavaScript

  2. 21 |
  3. JavaScript Syntax

  4. 22 |
  5. The Document Object Model

    23 |
      24 |
    • Test: alert title attribute
    • 25 |
    26 |
  6. 27 |
  7. A JavaScript image gallery

    28 | 34 |
  8. 35 |
  9. Best Practices

    36 |
      37 |
    • Example: unobtrusive popup window
    • 38 |
    39 |
  10. 40 |
  11. Image Gallery Revisited

    41 | 46 |
  12. 47 |
  13. Creating markup on the fly

    48 |
      49 |
    • Test: document.write inline
    • 50 |
    • Test: document.write external
    • 51 |
    • Test: alert innerHTML
    • 52 |
    • Test: updating innerHTML
    • 53 |
    • Test: alert node info
    • 54 |
    • Test: createElement
    • 55 |
    • Test: createTextNode
    • 56 |
    • Test: appendChild
    • 57 |
    • Test: documentFragments
    • 58 |
    • Test: documentFragments
    • 59 |
    60 |
  14. 61 |
  15. Enhancing content

    62 | 67 |
  16. 68 |
  17. CSS-DOM

    69 |
      70 |
    • Example: alert changed style info
    • 71 |
    • Itinerary: striped table
    • 72 |
    • Story: styling first paragraphs
    • 73 |
    74 |
  18. 75 |
  19. Animated Slideshow

    76 | 82 |
  20. 83 |
  21. Putting it all together

    84 | 91 |
  22. 92 |
  23. The Future of DOM Scripting

  24. 93 |
94 | 95 |
96 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /chapter11/4. forms/modernizr-1.6.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Modernizr v1.6 3 | * http://www.modernizr.com 4 | * 5 | * Developed by: 6 | * - Faruk Ates http://farukat.es/ 7 | * - Paul Irish http://paulirish.com/ 8 | * 9 | * Copyright (c) 2009-2010 10 | * Dual-licensed under the BSD or MIT licenses. 11 | * http://www.modernizr.com/license/ 12 | */ 13 | window.Modernizr=function(i,e,u){function s(a,b){return(""+a).indexOf(b)!==-1}function D(a,b){for(var c in a)if(j[a[c]]!==u&&(!b||b(a[c],E)))return true}function n(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1);c=(a+" "+F.join(c+" ")+c).split(" ");return!!D(c,b)}function S(){f.input=function(a){for(var b=0,c=a.length;b7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&& 20 | o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize= 21 | function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients= 22 | function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective", 23 | "MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g, 24 | 0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"'); 25 | b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in 26 | i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&& 27 | /SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div"); 28 | a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&& 20 | o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize= 21 | function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients= 22 | function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective", 23 | "MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g, 24 | 0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"'); 25 | b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in 26 | i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&& 27 | /SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div"); 28 | a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&& 20 | o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize= 21 | function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients= 22 | function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective", 23 | "MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g, 24 | 0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"'); 25 | b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in 26 | i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&& 27 | /SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div"); 28 | a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m7)};d.history=function(){return!!(i.history&&history.pushState)};d.draganddrop=function(){return o("drag")&& 20 | o("dragstart")&&o("dragenter")&&o("dragover")&&o("dragleave")&&o("dragend")&&o("drop")};d.websockets=function(){return"WebSocket"in i};d.rgba=function(){j.cssText="background-color:rgba(150,255,150,.5)";return s(j.backgroundColor,"rgba")};d.hsla=function(){j.cssText="background-color:hsla(120,40%,100%,.5)";return s(j.backgroundColor,"rgba")||s(j.backgroundColor,"hsla")};d.multiplebgs=function(){j.cssText="background:url(//:),url(//:),red url(//:)";return/(url\s*\(.*?){3}/.test(j.background)};d.backgroundsize= 21 | function(){return n("backgroundSize")};d.borderimage=function(){return n("borderImage")};d.borderradius=function(){return n("borderRadius","",function(a){return s(a,"orderRadius")})};d.boxshadow=function(){return n("boxShadow")};d.textshadow=function(){return e.createElement("div").style.textShadow===""};d.opacity=function(){var a=q.join("opacity:.5;")+"";j.cssText=a;return s(j.opacity,"0.5")};d.cssanimations=function(){return n("animationName")};d.csscolumns=function(){return n("columnCount")};d.cssgradients= 22 | function(){var a=("background-image:"+q.join("gradient(linear,left top,right bottom,from(#9f9),to(white));background-image:")+q.join("linear-gradient(left top,#9f9, white);background-image:")).slice(0,-17);j.cssText=a;return s(j.backgroundImage,"gradient")};d.cssreflections=function(){return n("boxReflect")};d.csstransforms=function(){return!!D(["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"])};d.csstransforms3d=function(){var a=!!D(["perspectiveProperty","WebkitPerspective", 23 | "MozPerspective","OPerspective","msPerspective"]);if(a)a=Q("@media ("+q.join("transform-3d),(")+"modernizr)");return a};d.csstransitions=function(){return n("transitionProperty")};d.fontface=function(){var a,b=e.head||e.getElementsByTagName("head")[0]||l,c=e.createElement("style"),k=e.implementation||{hasFeature:function(){return false}};c.type="text/css";b.insertBefore(c,b.firstChild);a=c.sheet||c.styleSheet;b=k.hasFeature("CSS2","")?function(g){if(!(a&&g))return false;var r=false;try{a.insertRule(g, 24 | 0);r=!/unknown/i.test(a.cssRules[0].cssText);a.deleteRule(a.cssRules.length-1)}catch(x){}return r}:function(g){if(!(a&&g))return false;a.cssText=g;return a.cssText.length!==0&&!/unknown/i.test(a.cssText)&&a.cssText.replace(/\r+|\n+/g,"").indexOf(g.split(" ")[0])===0};f._fontfaceready=function(g){g(f.fontface)};return b('@font-face { font-family: "font"; src: "font.ttf"; }')};d.video=function(){var a=e.createElement("video"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('video/ogg; codecs="theora"'); 25 | b.h264=a.canPlayType('video/mp4; codecs="avc1.42E01E"')||a.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"');b.webm=a.canPlayType('video/webm; codecs="vp8, vorbis"')}return b};d.audio=function(){var a=e.createElement("audio"),b=!!a.canPlayType;if(b){b=new Boolean(b);b.ogg=a.canPlayType('audio/ogg; codecs="vorbis"');b.mp3=a.canPlayType("audio/mpeg;");b.wav=a.canPlayType('audio/wav; codecs="1"');b.m4a=a.canPlayType("audio/x-m4a;")||a.canPlayType("audio/aac;")}return b};d.localstorage=function(){try{return"localStorage"in 26 | i&&i.localStorage!==null}catch(a){return false}};d.sessionstorage=function(){try{return"sessionStorage"in i&&i.sessionStorage!==null}catch(a){return false}};d.webWorkers=function(){return!!i.Worker};d.applicationcache=function(){return!!i.applicationCache};d.svg=function(){return!!e.createElementNS&&!!e.createElementNS(v.svg,"svg").createSVGRect};d.inlinesvg=function(){var a=document.createElement("div");a.innerHTML="";return(a.firstChild&&a.firstChild.namespaceURI)==v.svg};d.smil=function(){return!!e.createElementNS&& 27 | /SVG/.test(O.call(e.createElementNS(v.svg,"animate")))};d.svgclippaths=function(){return!!e.createElementNS&&/SVG/.test(O.call(e.createElementNS(v.svg,"clipPath")))};for(var H in d)if(R(d,H)){w=H.toLowerCase();f[w]=d[H]();P.push((f[w]?"":"no-")+w)}f.input||S();f.crosswindowmessaging=f.postmessage;f.historymanagement=f.history;f.addTest=function(a,b){a=a.toLowerCase();if(!f[a]){b=!!b();l.className+=" "+(b?"":"no-")+a;f[a]=b;return f}};j.cssText="";E=h=null;i.attachEvent&&function(){var a=e.createElement("div"); 28 | a.innerHTML="";return a.childNodes.length!==1}()&&function(a,b){function c(p){for(var m=-1;++m final_x) { 83 | var dist = Math.ceil((xpos - final_x)/10); 84 | xpos = xpos - dist; 85 | } 86 | if (ypos < final_y) { 87 | var dist = Math.ceil((final_y - ypos)/10); 88 | ypos = ypos + dist; 89 | } 90 | if (ypos > final_y) { 91 | var dist = Math.ceil((ypos - final_y)/10); 92 | ypos = ypos - dist; 93 | } 94 | elem.style.left = xpos + "px"; 95 | elem.style.top = ypos + "px"; 96 | var repeat = "moveElement('"+elementID+"',"+final_x+","+final_y+","+interval+")"; 97 | elem.movement = setTimeout(repeat,interval); 98 | } 99 | 100 | function prepareSlideshow() { 101 | if (!document.getElementsByTagName) return false; 102 | if (!document.getElementById) return false; 103 | if (!document.getElementById("intro")) return false; 104 | var intro = document.getElementById("intro"); 105 | var slideshow = document.createElement("div"); 106 | slideshow.setAttribute("id","slideshow"); 107 | var frame = document.createElement("img"); 108 | frame.setAttribute("src","images/frame.gif"); 109 | frame.setAttribute("alt",""); 110 | frame.setAttribute("id","frame"); 111 | slideshow.appendChild(frame); 112 | var preview = document.createElement("img"); 113 | preview.setAttribute("src","images/slideshow.gif"); 114 | preview.setAttribute("alt","a glimpse of what awaits you"); 115 | preview.setAttribute("id","preview"); 116 | slideshow.appendChild(preview); 117 | insertAfter(slideshow,intro); 118 | var links = document.getElementsByTagName("a"); 119 | for (var i=0; i 1 && field.value != field.placeholder); 354 | } 355 | 356 | function isEmail(field) { 357 | return (field.value.indexOf("@") != -1 && field.value.indexOf(".") != -1); 358 | } 359 | 360 | function prepareForms() { 361 | for (var i=0; i([\s\S]+)<\/article>/); 427 | if (matches.length > 0) { 428 | thetarget.innerHTML = matches[1]; 429 | } else { 430 | thetarget.innerHTML = '

Oops, there was an error. Sorry.

'; 431 | } 432 | } else { 433 | thetarget.innerHTML = '

' + request.statusText + '

'; 434 | } 435 | } 436 | }; 437 | 438 | request.send(data); 439 | 440 | return true; 441 | }; 442 | 443 | 444 | 445 | 446 | 447 | function loadEvents() { 448 | // home 449 | prepareSlideshow(); 450 | // about 451 | prepareInternalnav(); 452 | // photos 453 | preparePlaceholder(); 454 | prepareGallery(); 455 | // live 456 | stripeTables(); 457 | highlightRows(); 458 | displayAbbreviations(); 459 | // contact 460 | focusLabels(); 461 | prepareForms(); 462 | } 463 | 464 | // Load events 465 | addLoadEvent(highlightPage); 466 | addLoadEvent(loadEvents); 467 | 468 | --------------------------------------------------------------------------------