Client Side Technologies - DHTML
Client Side Technologies - DHTML
DHTML
DHTML = Dynamic HTML
It allows you to build rich client interfaces and to modify them dynamically
DHTML In A Nutshell
DHTML is too rich to cover in an hour
The technologies are way to rich to fully cover in this presentation. This presentation will: 1) Briefly introduce each technology with a quick example 2) Give a high-level overview of how to use each technology 3) Show some more advanced uses for the various technologies and review how each one works 4) Provide resources for further exploration of each technology
2005 evoch, LLC
HTML / XHTML
HTML = HyperText Markup Language
Allows you to define and structure the contents of your document. Latest (last?) version is 4.01.
CSS
CSS = Cascading Style Sheets
Allows you to define the styles to apply to your document. Latest version is 2.1.
Very powerful
CSS is much more powerful than HTML design tags
CSS Example
<STYLE TYPE="text/css"> BODY { background-color: #CCCCCC; }
DOM
DOM = Document Object Model
Defines a hierarchical model of the document structure through which all document elements may be accessed
Nodes
The W3C DOM defines element of a document is a node of a particular type
Node Types
Common types are: document node, element node, text node, attribute node, comment node, document-type node
2005 evoch, LLC
DOM Example
document node
element node <HTML> element node <HEAD> element node <TITLE> text node "Sample" element node <BODY> element node <P> text node "This is a..."
2005 evoch, LLC
JavaScript
JavaScript
Allows you to add conditional, client-side logic and behavior to your document
JavaScript != JAVA
Even though they have similar names, they are very different
Very powerful
Current versions are incredibly powerful... fully objectoriented, conditional logic, DOM interaction, more
2005 evoch, LLC
JavaScript Example
<SCRIPT TYPE="text/javascript"> <!-function pushButton() { if ( confirm("Push a button") ) { alert("You pushed \"OK\""); } else { alert("You pushed \"Cancel\""); } } // --> </SCRIPT>
2005 evoch, LLC
DHTML Example
Style Switcher
Using JavaScript, this example dynamically "applies" the selected CSS style sheet, changing the design on the fly. - JavaScript interacts with DOM and cookies - Shows ability of CSS to affect design w/o changing HTML
function setActiveStyleSheet(title) { var i, a, main; for(i=0; (a = document.getElementsByTagName("link")[i]); i++) { if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) { a.disabled = true; if(a.getAttribute("title") == title) a.disabled = false; } } }
2005 evoch, LLC
<LINK> tag
References external style sheets. Allows for alternates.
<LINK REL="stylesheet" HREF="default.css" TYPE="text/css">
STYLE attribute
Defines inline styles for a specific block of HTML code
<P STYLE="color: #FF0000; font-weight: bold;"> some text </P>
2005 evoch, LLC
CSS: Syntax
@import Directive
Loads an external style sheet. Does not allow alternates. Not supported in some older browsers.
Rules
Defines which styles to apply to which elements
Selectors
Specifies the element or type of element that style affects
Declarations
Specifies CSS properties and values
2005 evoch, LLC
font: arial;
Value Property
Selector Rule
element
Padding
Border Margin
2005 evoch, LLC
Event Attributes
Defines event handlers for events of specific elements
<INPUT TYPE="Button" onClick="alert('Hi there!');" VALUE="Hi"> <IMG SRC="blue.gif" onMouseOver="this.src='red.gif';" onMouseOut="this.src='blue.gif';" >
2005 evoch, LLC
JavaScript
Full, feature-rich language
Supports all standard control mechanisms: conditionals, loops, variables, try/catch/throw, functions, "objects"
Very powerful
Earlier versions were limited. Current version is not.