Ecommerce DHTML Notes
Ecommerce DHTML Notes
Prime Communications
DHTML
Introduction to DHTML
What you should already know
Before you continue you should have a basic understanding of the following:
WWW, HTML and the basics of building Web pages Cascading Style Sheets JavaScript
So what is DHTML?
To most people DHTML means a combination of HTML 4.0, Style Sheets and JavaScript. W3C once said this: "Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets and scripts that allows documents to be animated."
Page # 1/9
Prime Communications
With CSS we got a style and layout model for HTML documents. Creating dynamic HTML documents would not be possible without CSS.
Position
The position property gives us the opportunity to place the elements anywhere on the document.
position:relative
This property places the element based on (or relative to) its current position. H1 { position:relative; left:10; } This places the header 10 pixels to the right from where it is normally placed.
position:absolute
Page # 2/9
Prime Communications
Visibility
The visibility property determines if an element is visible or not.
visibility:visible
This property makes the element visible. H1 { visibility:visible; }
visibility:hidden
This property makes the element invisible. H1 { visibility:hidden; }
Z-index
The z-index property determines the placement order of the elements. H1 { z-index:1; } H2 { z-index:2; }
Page # 3/9
Prime Communications
The H1 element is placed before the H2 element, so if these two elements happen to be placed on top of each other, the H2 element is placed on top of the H1 element.
Filters
Internet Explorer 4.0 introduced the filter property to CSS. The filter property allows you to add more style effects to your text and images. H1 { width:100%; filter:glow; } The element you want to add a filter to, must have a specified width. There are many values to the filter property, this example shows the "glow" value, which produces this output:
Header
All the values have arguments that allow you to control the filters.
Filters
Property alpha Value opacity finishopacity style startx starty finishx finishy add direction strength color none none color strength none Syntax filter:alpha(opacity=20, finishopacity=100, style=1, startx=0, starty=0, finishx=140, finishy=270) Explanation Allows you to set the opacity of the element
blur
Makes the specified color transparent Flips the element horizontally Flips the element vertically Makes the element glow Renders the element in black and white
Page # 4/9
Prime Communications
Renders the element in its reverse color and brightness values Renders the element with the specified background color, and transparent foreground color Renders the element with a shadow
shadow
color direction
filter:shadow(color=#ff0000, direction=90);
add filter:wave(add=true, freq=1, freq lightstrength=3, phase=0, lightstrength strength=5) phase strength none filter:xray;
xray
Renders the element in black and white with reverse color and brightness values
Background
The background property allows you to select your own background, in any style.
background-attachment:scroll
The background scrolls along with the rest of the page.
background-attachment:fixed
The background does not move when the rest of the page is scrolling.
Page # 5/9
Prime Communications
HTML 4.0 introduced the Document Object Model, which gives us access opportunity to every element in the document. It contains no functions or fancy layout tricks, it is more like a map of all the elements, and we use this map to access the elements.
My header
The DHTML Object Model
Object window document methods properties methods properties collections properties properties collections Explanation The window object is the top object in the DHTML Object Model, and gives you information about the window and the frames. The document object represents the HTML document, and gives you access to the HTML elements. The navigator object gives you information about the user's browser. The event object gives you information about events that occur.
navigator event
Page # 6/9
Prime Communications
With event handlers you can change all the elements whenever you want. When the user clicks an element, when the page loads, when a form is submitted, and more, but you need help from JavaScript, a small line of code in the value of the event handler. <h1 onclick="style.color='red'">Click on this text</h1> This makes a header which turns red when a user clicks on it. Or you can write the script as a function and place it in the head section of the page, then you have to call the function from the event handler: <html> <head> <script type="text/javascript"> function changecolor() { header.style.color="red" } </script> </head> <body> <h1 id="header" onclick="changecolor()"> Click on this text</h1> </body> </html> This method is preferred if you have many lines of code to be executed.
Page # 7/9
Prime Communications
User released a pressed mouse-button User resets a form User selected content of a page User submitted a form User left window
DHTML
With CSS, we can change the style of any HTML element. With the DOM, we have a map of all the elements in an HTML page. With a scripting language, we can access the elements in the DOM. With event handlers, we can access these scripts at any time. Now you have endless possibilities to make dynamic web pages.
CSS Position:relative Position:relative Position:absolute Visibility Z-index Z-index Vice Versa Cursors Filters Filters on Images Filter:mask image Filter:mask text Filter light effect Filter moving light effect Watermark Change background color
Page # 8/9
Prime Communications
Page # 9/9