Some useful javascript snippets

In: Uncategorized

9 Sep 2009

A couple of useful snippets to use in the console ….

// sometimes you want to quickly count all elements in a page
// to see how heavy it is. when you have more elements,
// it takes longer to search all of them in your RIA
document.getElementsByTagName('*').length;

// add a stylesheet dynamically
// this can be useful when diagnosing a print css file
// or any instance when certain styles may not be applied
// until a particular context or event
var fileref=document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", '/css/my-css-file.css');
document.getElementsByTagName("head")[0].appendChild(fileref);

About this blog

This portifolio represents a brief sampling of my work. More thorough demonstrations and walk-thrus of my latest and greatest work are available via remote virtual session on DimDim, a free flash based web conferencing tool.

Also note that I recently joined StackOverflow where you will find me asking and answering many web development questions.