Presentation is loading. Please wait.

Presentation is loading. Please wait.

Pemrograman Teknologi Internet W09: DOM & DHTML. 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing.

Similar presentations


Presentation on theme: "Pemrograman Teknologi Internet W09: DOM & DHTML. 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing."— Presentation transcript:

1 Pemrograman Teknologi Internet W09: DOM & DHTML

2 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing & Modifying DOM Trees DOM Collections DOM Collections Dynamic Styles Dynamic Styles DHTML (IE Only) DHTML (IE Only) Filter & Transitions Filter & Transitions

3 DOM DOM stands for Document Object Model DOM stands for Document Object Model DOM is a cross-platform and language- independent convention for representing and interacting with objects in HTML, XHTML and XML documents. DOM is a cross-platform and language- independent convention for representing and interacting with objects in HTML, XHTML and XML documents. 3

4 Object Referencing The simplest way to reference an element is by using the element’s id attribute. The element is represented as an object, and its various XHTML attributes become properties that can be manipulated by scripting The simplest way to reference an element is by using the element’s id attribute. The element is represented as an object, and its various XHTML attributes become properties that can be manipulated by scripting 4

5 Using id (IE Only) Intro Welcome to our Web Page! Welcome to our Web Page! 5 Welcome to our Web Page.", "description": "Welcome to our Web Page. 5.", "width": "800" }

6 Collections ‘all’ The all collection is a collection of all the XHTML elements in a document, in the order in which they appear. The all collection is a collection of all the XHTML elements in a document, in the order in which they appear. This provides an easy way of referring to any specific element, especially if it does not have an id. This provides an easy way of referring to any specific element, especially if it does not have an id. 6

7 Collections ‘all’ var elements = ""; function start() { for (var loop = 0; loop < document.all.length; ++loop) elements += " " + document.all[loop].tagName; pText.innerHTML += elements; alert(elements);} 7

8 Collections ‘children’ A collection similar to the all collection is the children collection, which for a specific element contains that element’s child elements. A collection similar to the all collection is the children collection, which for a specific element contains that element’s child elements. For example, an html element has only two children—the head element and the body element. For example, an html element has only two children—the head element and the body element. 8

9 Collections ‘children’ var elements = " "; function child(object) { var loop = 0; elements += " " + object.tagName + " "; for (loop = 0; loop < object.children.length; loop++) { if (object.children[loop].children.length) child(object.children[loop]);else elements += " " + object.children[loop].tagName + " "; } elements += " "; } 9

10 Dynamic Styles An element’s style can be changed dynamically. An element’s style can be changed dynamically. For example: For example: the background color as document.body.style.backgroundColor the background color as document.body.style.backgroundColor the body property of the document object refers to the body element. the body property of the document object refers to the body element. the style object (a property of most XHTML elements) to set the background-color CSS property the style object (a property of most XHTML elements) to set the background-color CSS property 10

11 Dynamic Styles 1 function start() { var inputColor = prompt("Enter a background color name"); document.body.style.backgroundColor = inputColor; } 11

12 Dynamic Styles 2 CSS Demo CSS Demo.bigText { font-size: 3em; font-weight: bold }.smallText { font-size:.75em } 12

13 Dynamic Styles 2 Welcome to our Web page! Welcome to our Web page! 13 Welcome to our Web page.", "description": "Welcome to our Web page. 13.", "width": "800" }

14 Dynamic Positioning Another important feature of Dynamic HTML is dynamic positioning, by means of which XHTML elements can be positioned with scripting. Another important feature of Dynamic HTML is dynamic positioning, by means of which XHTML elements can be positioned with scripting. This is done by declaring an element’s CSS position property to be either absolute or relative, and then moving the element by manipulating any of the top, left, right or bottom CSS properties. This is done by declaring an element’s CSS position property to be either absolute or relative, and then moving the element by manipulating any of the top, left, right or bottom CSS properties. 14

15 Dynamic Positioning Dynamic Positioning Dynamic Positioning Welcome!

17" class="image_link uk-text-large uk-margin-small-left uk-margin-small-right">17 Dynamic Positioning // --> Welcome!

17 Welcome!

17", "description": "Dynamic Positioning // --> Welcome!

17", "width": "800" }

18 Object Model Chart 18

19 Filter and Transitions The difference between Filter and Transition: The difference between Filter and Transition: Applying filters to text and images causes changes that are persistent. Applying filters to text and images causes changes that are persistent. Transitions are temporary Transitions are temporary Filters and transitions do not add content to your pages—rather, they present existing content in an engaging manner to capture the user’s attention Filters and transitions do not add content to your pages—rather, they present existing content in an engaging manner to capture the user’s attention 19

20 Flip Filter Intro body { background-color: #CCFFCC } table { font-size: 3em; font-family: Arial, sans-serif; background-color: #FFCCCC; border-style: ridge; border-collapse: collapse } td { border-style: groove; padding: 1ex } 20

21 Flip Filter

Text Text Text Text
Text
21

22 Adding Shadow to Text A simple filter that adds depth to your text is the shadow filter. A simple filter that adds depth to your text is the shadow filter. This filter creates a shadowing effect that gives your text a three-dimensional appearance. This filter creates a shadowing effect that gives your text a three-dimensional appearance. 22

23 Adding Shadow to Text Shadow Shadow Direction: 0 Shadow Direction: 0 23

24 Making Text Glow The glow filter adds an aura of color around text. The glow filter adds an aura of color around text. The color and strength can both be specified as demonstrated in the following code: The color and strength can both be specified as demonstrated in the following code: Glowing Text Glowing Text 24

25 Other Filter Effects: Gradient To create gradient effects dynamically, using the alpha filter. To create gradient effects dynamically, using the alpha filter. The style property of the filter determines in what style the opacity is applied: The style property of the filter determines in what style the opacity is applied: a value of 0 applies uniform opacity, a value of 0 applies uniform opacity, a value of 1 applies a linear gradient, a value of 1 applies a linear gradient, a value of 2 applies a circular gradient a value of 2 applies a circular gradient and a value of 3 applies a rectangular gradient. and a value of 3 applies a rectangular gradient. The opacity and finishopacity properties are both percentages determining at what percent opacity the specified gradient will start and finish, respectively. The opacity and finishopacity properties are both percentages determining at what percent opacity the specified gradient will start and finish, respectively. 25

26 Other Filter Effects: blur The blur filter creates an illusion of motion by blurring text or images in a certain direction. The blur filter creates an illusion of motion by blurring text or images in a certain direction. The blur filter can be applied in any of eight directions, and its strength can vary. The blur filter can be applied in any of eight directions, and its strength can vary. The add property, when set to true, adds a copy of the original image over the blurred image, creating a more subtle blurring effect. The add property, when set to true, adds a copy of the original image over the blurred image, creating a more subtle blurring effect. The direction property determines in which direction the blur filter will be applied. This is expressed in angular form (as with the shadow filter). The direction property determines in which direction the blur filter will be applied. This is expressed in angular form (as with the shadow filter). The strength property determines how strong the blurring effect is. The strength property determines how strong the blurring effect is. 26

27 Transition The transitions included with Internet Explorer give the author control of many scriptable PowerPoint type effects. The transitions included with Internet Explorer give the author control of many scriptable PowerPoint type effects. Transitions are set as values of the filter CSS property, just as regular filters are. Transitions are set as values of the filter CSS property, just as regular filters are. We then use scripting to begin the transition We then use scripting to begin the transition A simple example is the blendTrans transition, which creates a smooth fade-in/fade-out effect. A simple example is the blendTrans transition, which creates a smooth fade-in/fade-out effect. 27

28 blendTrans Using blendTrans Using blendTrans 28 28", "description": "blendTrans Using blendTrans Using blendTrans 28", "width": "800" }

29 blendTrans Some fading text Some fading text

29


Download ppt "Pemrograman Teknologi Internet W09: DOM & DHTML. 2 Objectives DOM: DOM: DOM Nodes & Trees DOM Nodes & Trees Traversing & Modifying DOM Trees Traversing."

Similar presentations


Ads by Google