Archive for December, 2006

No more GetElementbyID

Dec 06
28

Here’s a simple script:

<div id=”‘hello’”>Hello World. </div>

<script type=”‘text/javascript’”>

var test=document.getElementById(‘hello’);

test.appendChild(document.createTextNode(‘Goodbye World’));
</script>

This is your basic example of DOM manipulation. You create a variable and start manipulating the document based on that element. But here’s something I bet you didn’t know. That first line is not needed:

<div id=”‘hello2′”>Hello World. </div>

<script type=”‘text/javascript’”>
hello2.appendChild(document.createTextNode(‘Goodbye World’));
</script>

Anytime you create an element with an ID a variable with the same name is automatically available for you to use.

(Update: After some explorations it turns out that although this does sometimes work it’s unreliable in strict mode. It’s probably not recommended for general use)

Winter updates

Dec 06
21

I hear that hard drive spinning up
The fans are spinning up too.
Come on, it’s lovely weather
To install an update or two.

I hear your family asking
And friends are asking you too.
Come on, and fix my computer
I have some spyware for you.

Double-click, double-click, double click, let’s go
The warm CRT glow
Let’s look at the progress bar it’s starting to grow

Double-click, double-click, double click, it’s grand
Just holding your hand
We install along with a song
In an obsolete wonderland!

Your modem’s nice and noisy
And comfy cozy are we
We’ll be here hours together
As we update a driver or three

Let’s take that upgrade before us
And sing a chorus or two
Come on, it’s lovely weather
To install an update or two.

I installed a virus blocker on your fresh install
It’ll finally bring that progress bar back from its crawl
We’ll be opening sites and pages
Without refresh and stop
And in the browser we will watch the popups pop
(Pop pop pop!)

There is something on your drive that even I can’t fix
Have you really been web browsing years with IE6
Has it really been another year since our last install
Your software needs another kick
From what I can recall.

I hear that hard drive spinning up
The fans are spinning up too.
Come on, it’s lovely weather
To install an update or two.

I hear your family asking
And friends are asking you too.
Come on, and fix my computer
I have some spyware for you.

Happy Holidays!

- Greg

P.S. You can read last years holiday poem here.