subsection contents

Random Banner-gram

This little JavaScript application demonstrates a way of locating tags using the getElementsByName() function, and changing the content of any tags found. It also shows some possibly humorous anagrams of my name :)

When the page is loaded, the banner and the coloured box below contain a randomly selected anagram of my name. If you move the mouse pointer into the box (or the banner) containing the anagram, the text is unscrambled and replaced by my name. Move it back out and another randomly selected anagram is displayed.

Unfortunately, Opera and Internet Explorer don't allow name attributes for h3 tags. The script checks for browsers that don't support getElementsByName() for all tags, and adjusts the DOM to include a named tag that those browsers do support. Thanks to Bennett/semicolon for tips on Setting the "name" attribute in Internet Explorer. Hovering over the green box below will now result in changes to the anagram text, but hovering over the text causes the colour to change prematurely back to green. I might fix that another time.


Bruno Andrighetto


Last updated: May 7, 2008