JS: Clear Default Value onFocus

Simply add the following to the the onFocus attribute of any HTML form input tag.
[code lang=”JavaScript”]if (this.value == this.defaultValue) this.value = ”;[/code]
this.defaultValue is automatically given the value in the HTML.

Append to Body onLoad

I looked for a long time how I could add JavaScript functions to an HTML document’s onLoad attribute.

Eventually I found this, something so obvious that I had considered trying it but foolishly didn’t try.

[code lang=”JavaScript”]
var oldLoad = window.onload;
window.onload = function() {
oldLoad();
function2();
}
[/code]

Google SketchUp (free)

Google (who recently bought SketchUp) have split it into two products.
There is now the free version ‘Google SketchUp‘, and SketchUp Pro.

The more important part of the news release, as far as I’m concerned, is the 3D Warehouse, a user-contributed collection of SU components – essentially a direct competitor to my SketchUp Components Collection.

I’m glad there is now a free version, but of course have some reservation over the launch of the 3D Warehouse.
This is the first time that Google has directly affect me personally. (Chances are that the SCC will suffer)

jsReq

I wanted to tell the user that they need JavaScript, but obviously only if they don’t already have it enabled.
The following is a very crude script which uses the very fact that JS is available to hide the requirement notice…

HTML:
[code lang=”html”]

Warning!
You need to have javascript enabled to use this page.

[/code]

JS:
[code lang=”JavaScript”]
function removeElementById(eleId) {
eleId = document.getElementById(eleId);
if (eleId.parentNode && eleId.parentNode.removeChild) {
eleId.parentNode.removeChild(eleId);
}
}
removeElementById(“jsRequiredDiv”);
[/code]