JavaScript language does not provide us a function for obtaining elements by class, only by id, name, and tag name. This JavaScript snippet will accomplish that, and includes optional arguments with defaults and support for multiple classnames in any order. It works in Internet Explorer, Firefox, Opera, Safari and Mac.
If your visitor is using Internet Explorer as their browser, this script will politely suggest Firefox as an alternative browser, maybe your users will remove IE like you; it is not windows notification, browser alert only. Just add it to the head of your page. Very simple!
This browser sniffer detects all the major browsers currently out there, and passes the results on as variables to facilitate your browser detection needs. It differentiates between Windows, Mac and Linux, and the most commonly used DHTML browsers - IE4/5/6, Netscape 4/6/7/other Gecko, Konqueror 2.2+, Safari, Opera 5/6/7. All other browsers are grouped together under a single exclude variable, to protect them from complex scripting.
Let use this simple JavaScript if you want to use the DOM to include a cascading style sheet. Very simple to implement and customize.
This function script will return an array of tags based on DOM element, tag, and class name. For example, getElementsByClassName(document, 'tr', 'info') will return to you an array of all "tr" tags under the document node having the "info" class.
This script uses className to make drag and drop feature for objects as dragable div, dragable layer. Very easy to use and customize.
Let use this JavaScript code if you want to load serval functions with onLoad event. Very short script and easy to use, but you can load unlimited functions.
Sometimes we need to display current URL on page, and web developers usually provide the entire path with breadcrumb, certainly. these scripts will be complex. But if you only want simple JavaScript to do this, let place six code lines on where you want to display URL document.
Normally, web developers will place CSS code into a pair of tags such as or to a CSS file. But in this snippet, we are creating CSS within JavaScript definition that browsers still understand these CSS properties. Although this CSS example is more complex than old CSS definition, but it is one of ways to develop website; you may consider this is CSS tutorial which quite worthy to see.


17/04/2009
0




