Archive for the 'Internet' Category

Understanding CSS DOM

The CSS DOM is a unconventional term used to define the application of CSS in HTML DOM. With this you can apply CSS style definitions to any object using DOM. Now you are already aware about basics of DOM.

To start with as usually you should know little HTML, CSS, Javascript & Dreamweaver MX or later. CSS DOM works similarly as CSS but, you are applying it through DOM using JavaScript.

There are basically two methods to apply DOM CSS to an element:

  1. Direct CSS class application method
  2. DOM Style method

Direct CSS class application method

In this method you are going to apply an already existing CSS class to an HTML element using JavaScript. Here’s the example.

Here’s a DIV tag where a CSS class applied to it,

<div id=”myObject” class=”sampleClass”>My HTML Object</div>

.sampleClass {
color: #000000;
text-decoration: none;
}
.newClass {
color: #FFFFFF;
text-decoration: underline;
}

Now I’m going to manipulate the CSS class name into a different one using JavaScript.

Function ChangeClass() {
document.getElementById(“myObject”).className=”newClass”
}

We’ve to trigger this function using any methods discussed in the previous article.

<input type=”button” name=”button1″ onclick=”ChangeClass()” />

DOM Style Method

This is a very common method used to apply CSS style definition to any object without having any existing CSS class. Here is an example.

<div id=”myObject”>My HTML Object</div>

Now I’m going to apply style definitions to this object,

Function ApplyStyle() {
document.getElementById(“myObject”).style.color = “#000000”
document.getElementById(“myObject”).style.fontFamily = “verdana”
document.getElementById(“myObject”).style.fontSize = “11px”
document.getElementById(“myObject”).style.display = “inline”
}

Same way we’ve to trigger this function using any methods discussed in the previous article.

<input type=”button” name=”button1″ onclick=”ApplyStyle()” />

More DOM CSS properties

Help from Dreamweaver 8 method

For more DOM CSS properties you can refer to “Reference” section of Dreamweaver MX or later. To do it follow this procedure: Goto ”Window” menu from menu bar and select “Reference” or press “Shift + f1″ key to open reference window. From “Book” dropdown select “O’RIELLY CSS Reference”. Now select any definition name from “Style” dropdown, and say “font-family” or “Background”. Now you can see detailed description about the each attribute and their values. Look for “Object Model Reference” you will find the way to locate the object(document.getElementById), you can find all properties and values of that object. Similarly you can do this for almost all other styles too. You can execute all properties with the help of above mentioned examples.

Understanding HTML DOM

Have you ever tried to get the HTML values inside a DIV or TABLE element or have you tried to make a SPAN tag behave like DIV and vice versa. If you haven’t tried this till now then, I could say it’s possible with HTML DOM and it can be controlled using JavaScript.

To start with all you need to know is little HTML, JavaScript, CSS & Dreamweaver 8. DOM stands for Document Object Model or in my own words skeleton of a browser and is a W3C recommendation. You can play with any HTML object displayed over the browser the way you play with movieclip & component objects in flash. Fine, now lets go in-depth.

Working with DOM

HTML DOM has a structure similar to HTML, like Element(tag) , Attribue & Value. For example in html its

<body background=”bgimage.gif”>

Where “body” is element, “background” is attribute and”bgimage.gif” is value. Similarly in DOM its,

document.body.background=”bgimage.gif”

Where “document.body” is element, “background” is attribute/property and “bgimage.gif” is value.

Now lets try applying it through javaScript:

funtion applyBg() {
document.body.background=”bgimage.gif”
}

Now we have to trigger this JavaScript function using event handler called “onclick” through a simple form button;

<input name=”button1″ type=”button” value=”Change Background” onclick=”applyBg()”

By this way you can change the property of an HTML/browser element.

Hope now at this stage after trying these code example you have come into a conclusion about DOM, lets take one more DOM example on form elements:

document.myform.textbox1.value = “Hello! Brother”

Where “document.myform” is the form name, “textbox1” is the text box object name and “Hello! Brother” is the value to be populated inside the text box. Even this can be triggered in the same way as mentioned in the previous example within a JavaScript function. The properties & values does varies from one element to other element in a document.

DOM Basics

Basically, there are three important things to know to master DOM, one identify/locate the object, second look for properties & values for that object and third event handler to trigger the function.

Locating/identifying an Object

There are mainly three methods to locate an object:

  1. Direct Method
  2. Form Method
  3. GetElementById / GetElementByName / GetElementByTagName Method

Direct Method

These are identifiers which are already inbuilt for unique HTML/browser components, for examaple:

document.body.property=”value” – for body element
document.links[i].property=”value” – for links
document.appletName.property=”value” – for applets and many more

Form Method

These identifiers are only restricted to form & form elements like, button, text box, combo box(dropdown), textarea, radiobutton, checkbox etc; For example:

document.formName.elementName.property=”value”

GetElementById Method

This is an unique and independent method of locating an object. Any object can be accessed by assigning an id=”idName” attribute into any element. For example:

<div id=”idName”>Hello! Brother</div>

document.getElementById(“idName”).property=”value”

For example: function to read an HTML code from a DIV element and populate it to a Textarea:

<div id=”getCode”><table width=”100%” border=”0″ cellpadding=”2″ cellspacing=”2″><tr><td>This is a sample content</td></tr></table></div>
<textarea cols=”10″ rows=”5″ name=”putCode”>No Data</textarea>

document.form1.putCode.value = document.getElementById(“getCode”).innerHTML;

There are other similar methods resembling to GetElementById, those are GetElementsByName and GetElementsByTagName. The “GetElementsByName” is used similar as GetElementById. Whereas “GetElementsByTagName” just only looks for particular tags like and can only be used alongwith “GetElementById” or “GetElementsByName” identifier.

Setting Atrribute Values to the Objects

Help from Dreamweaver 8 method

For more elements & attributes/properties you can refer to “Reference” section of Dreamweaver MX or later. To do this follow this procedure: Goto”Window” menu from menu bar and select “Reference” or press “Shift + f1” key to open reference window. From “Book” dropdown select “O’RIELLY JavaScript Reference”. Now select any element name from “Object” dropdown, say “body” and select any attribute/property from the next dropdown. Now you can see detailed description about the each attribute and their values. Look for “Object Model Reference” you will find the way to locate the object(document.body), you can find all properties and values of that object including event handlers for individual objects. Similarly you can do this for almost all other objects too. You can execute all properties with the help of above mentioned examples.

Event Handlers

Event handlers are used to trigger one or more JavaScript functions. Event handlers differ from one object to the other. Here are few common examples:

Body Element
onload – Triggers when page loads
onunload – Triggers when page unloads
onafterprint – Triggers when before page loads
onbeforeprint – Triggers when after page loads

Common
onclick – triggers when user clicks that object
onblur – triggers when loses focus
onfocus – triggers when gets focus
onmouseover – triggers when mouse pointer moves over the object
onmouseout – triggers when mouse pointer moves out of the object
onmousedown – triggers when mouse button is on pressed state
onmouseup – triggers when mouse button is released after pressed state

Textboxes
onchange – Triggers when the value or selection changes inside the component (also applies for list element)
onselect – Triggers when the value inside the textbox is selected
onkeydown – Triggers when any key on the keyboard in the pressed state
onkeyup – Triggers when any key on the keyboard is released after pressed state
onkeypress – Triggers this event between onkeydown and onkeyup state

Feature Fight: Vista vs. Tiger

Vista Vs. Tiger

Feature Fight: Vista vs. Tiger


Microsoft Windows Vista

  • Codename: Longhorn
  • Released: January 30,2007
  • GUI: Aero-Glass

Apple Mac OS X 10.4 Tiger

  • Codename: Not known
  • Released: April 29, 2005
  • GUI: Aqua

Now we are going to discuss the GUI relativity of Vista over Apple Mac OS X Tiger. Even we are going to discuss the relativity on features of Mac OS X Leopard over Vista.

This became even more controversial when the Microsoft Windows Vista released developer Beta for testing on completion of development in November 10, 2006. Most of the developers criticized it for its relativity in GUI with Tiger. Even now we are going to do the same thing through feature by feature and point by point.

Aero-Glass Theme:
The A.E.R.O. stands for Authentic, Energetic, Reflective and Open. The theme which comprises of entirely new look and feel out of its predecessors like windows 95/98/2000/XP. Here are the similarities compared with Tiger:

  • Transparency/Translucency/Opacity:
    Aero-Glass has the transparency appeal to it and applied to its window pane, Start Menu, Menu and Desktop Icons. Similar to translucent theme on Tiger.
  • Live Shadow:
    All the window and menu elements does have a Flat Shadow around them, but more sleek and intuitive than Tiger.
  • Icons:
    All the icons created are either 3D or 2D multicolored with shadow. One can easily notice the Recycle Bin of Vista has 90% relation with Trash of Tiger.

Features:
Other than GUI there are highly noticeable features that has been used in Vista compared to Tiger.

  • Fast Search:
    This seems to be the replica of Spotlight in Tiger, where the file search has been improved drastically. Give the search keyword/phrase within a blink of an eye search completed with results. One can easily spot the Search(magnifier) button icon in Vista where it is placed towards the right of text input box, whereas in Tiger the same icon already placed on the left of text input box.
  • Desktop Widget:
    This one I found not only similar to Dashboard of Tiger, but even with Yahoo Widgets by Yahoo Inc. Where one can see a analog clock, Weather, Stock Details, Maps, and lot more to be mounted on the desktop.

Hope this is evident enough to prove that Microsoft have done some copycatting in its new product “Vista” , now we can even call this as rival copycatting.

Now, its time to drag the Apple to courtroom. Where Apple releasing Mac OS 10.5 Leopard, few features found similar with Windows Vista.

Features:
These are noticeable features that are found in Leopard compared to Vista.

  • Time Machine:
    These features found specifically in Windows XP as System Restore and even same have been improved in Vista. The Time Machine seemed to be more advanced compared to System Restore. System Restore can only restore the system files such a DLLs, INIs and few EXEs, whereas in Time Machine it can even restore user created files such as photos, movies, and other documents including system settings.
  • Spaces:
    This is similar and again advanced to multiple Users feature of Windows XP & Vista.

Hope we’ve covered enough criticism against both the parties. Looking for your feedback on the quality of article. If you think any modifications needed into the article, we whole heartedly welcome your suggestions.

For Reader’s reference:
Apple Mac OS X Tiger: www.apple.com/macosx/tiger
Apple Mac OS X Leopard: www.apple.com/macosx/leopard
Microsoft Windows Vista: www.microsoft.com/vista