what makes your world go round? Javascript Tricks Page
another Complete Waste of Time
what makes your world go round?

HOME | WEIRD | INVEST | MEDIA | MY NEWS | SIGN IN | SEARCH

by Mathew Ingram

Ever wondered what you can do with Javascript? Well, you can do a lot of useful things -- none of which are described here. Instead, there's lots of stupid things you can do to annoy your friends. If you're thinking that Javascript is "programming" and therefore hard, you couldn't be more wrong. Most of these tricks I stole... er, borrowed from other people. You're welcome to do the same.


| Alert | onMouseOver | Buttons | onLoad | Writing | Dating | Clock of Doom | Delete | Rock, Paper, Scissors | Colour | Refer | More Useless Crap |



The Alert Object

One of the simplest Javascript resources is the alert object. Its sole purpose is to pop up a box with a simple message and a button to close the box. If you look at the source code of this page, you can see it uses the onClick function.


OnMouseOver

You can also use the OnMouseOver attribute to bring up an alert, or a new window, or to change images on the fly. The last one also uses the related function called onMouseOut to return to the previous image when the cursor moves away. Move your mouse pointer close to here or here.

Top

Using Buttons

Using the Javascript onClick event handler and a related function, you can do a lot -- you can call up separate windows, or execute functions of various kinds. Click on the button below to see how to use a button and the onClick event to open a new window.


You can also use the same new window-opening feature in conjunction with another function -- for example, Javascript can suck information from your browser about its identity, something which it delivers when it connects to a page, and you can display that information in a new window.


Top

The OnLoad Function

Just like onMouseOver and onClick, you can have Javascript perform functions when a user first loads your page. For example, if you look at the source code, you can see that this page is set to grab the time from your computer and display it once the page is finished loading. You can also use the corollary of onLoad, which is (obviously) onUnload -- but you'll have to leave to try it out.
Time: Date:


Top

Writing Things

You can use the simple document.write command within a script to write whatever you want on a page. The greeting at the top in green was generated that way -- it gets your browser to say what time it is (information it gets from your computer's internal clock), then chooses an appropriate greeting. It then uses the "document.write" command to add it to the page.

Top

Dating Your Pages

Using JavaScript and the lastModified property, you can put a few lines at the bottom of your pages to show when you last modified your page. The date and time at the bottom of the page were generated by such a script. Just do a "view source" and you can see how simple it is.

Top

The Clock 'O Doom

This one I picked up in my travels looking for Java stuff -- fill in your birthdate and it'll add up how many seconds you've been alive... and count down the seconds as you're watching. Give it a try.


Top

Hard Drive Deletion

Wanna have some fun with someone who doesn't know much about computers? Send them to this page and then watch their face...


Top

Rock, Paper, Scissors

Sure, there's lots of fancy-pants 3D computer games you can buy for $100 that need a Pentium IX 3000 Megahertz computer to run, but what kind of fun is that? Use a little Javascript to play some good old-fashioned Rock, Paper, Scissors...


More Useless Crap



Top

Background Color Changer

Using a simple Javascript (which you can see by doing a "view source" on this page) you can allow surfers to change the background color of your page on the fly. Give it a try -- I recommend the "papayawhip".

Top

You can also modify the same script to send someone to another page by clicking a selection.

HOME | WEIRD | INVEST | MEDIA | MY NEWS | SIGN IN | SEARCH

best viewed with any damn browser You are visitor number:
take a wild guess
made with recycled electrons