My Favorite Javascripts for Designers
October 14, 2004
Are there certain javascripts that you seem to always use from project to project? Lately, I have seen javascript being used more and more effectively on websites. For example, Gmail’s user interface and Mike Davidson’s sIFR technique. How we use javascript on a website can certainly make a website experience better and more enjoyable. I will never proclaim to be a javascript expert or even write javascript from the scratch. On the other hand, I do excel at the copy, paste, and tweak method.
Some of the reasons I use javascript are, (1) it can’t be done with CSS, (2) it is client-side making things fast, and (3) it improves the user experience. Simple, fast and effective javascript is what I like when using a javascript script. So, these are the ones that made my list. What would you put on your list? They are in no paticular order and example follow with each.
My top javascripts
- ExpandCollapse
-
Used for expanding and collapsing block elements. I use this one for hiding divs or expanding the divs for forms. Very useful.
function expandCollapse() { for (var i=0; i<expandCollapse. » arguments.length; i++) { var element = document.getElementById » (expandCollapse.arguments[i]); element.style.display = (element.style. » display == "none") ? "block" : "none"; } }Example:
- Timer Layer
-
Used for hiding an element after ‘x’ of seconds. Great for hiding status messages after a person has submitted a form.
var timerID; function ShowLayer(id) { document.getElementById().style.display = "block"; } function HideTimedLayer(id) { clearTimeout(timerID); document.getElementById(id). » style.display = "none"; } function timedLayer(id) { setTimeout("HideTimedLayer(\"" + id + "\")",» 5000); //5000= 5 seconds }Example:
- Style Switcher
-
Paul Sowden’s article on A List Apart’s about switching styles and saving that style with cookie is awesome. I’ve used it from changing font-sizes to changing the complete layout and color of a site. Very useful when a site is built with CSS.
Example:
This is simple change of the background color on this site Background Blue Background Brown
- Form Checker
-
Probably one of the most useful scripts and there are several out there about form validation. This figures out what fields are required from the value in in a hidden
inputtag. Than it highlights the error areas.function check_required(myForm) { var requiredFields = myForm.required.value.split("|"); var errorString = ''; for (var i=0; i<requiredFields.length; i++) { var parts = requiredFields[i].split(","); var field = parts[0]; var title = parts[1]; … Show Full ScriptExample:
- Drop Down Navigation.
Nothing beats HTML Dog’s Sons of Suckerfish dropdown navigation. It can be argued that it is not as usable as static navigation, but when you need it or it is requested Patrick Griffiths and Dan Webb have a script that is light, simple, valid, and a beautiful combination of CSS and javascript.
Example: used on IAB website.
Download all of the scripts above here in this one file.
A Reader's Toolbox The Microsoft certified of MB2-422 and 220-602 are expert professionals of trouble shooting with windows backup problems. Whenever some virus attacks your system, it damages all existing data in your hard drive. You can perform disk recovery operations with the help of antivirus software that kills viruses and scans your pc. It's also recommended for keeping your chat software safe from virus.
I like a few small ones. My new LiveSearch one is likely to get a lot more use. Form validation is great, as long as it's just there to save some time and server-side validation is in place. A javascript to check font sizing on pages (when using relative sizes) and increase it if below a minimum is also one I use regularly.
Nice list - and it's nice to see JavaScript being used more sensibly nowadays.
Posted on Oct. 14, 2004 05:06 #