Useful javascript

Although I probably haven’t bitched about it on here — at least recently — but I’m generally opposed to the use of javascript on the web. At least I am opposed to the use that I see it in most of the time. Javascript should augment the user experience but not be the only way for something to function. One of the big offenders is Javascript menus. I’ve seen a few that Opera for Linux just doesn’t render because the code is geared to IE. Avoiding dependance on the client only helps with your site. I would much rather see CSS based menus even if they aren’t as supported yet.

However there are a couple of things that I don’t mind. Setting focus on a form field when the page loads is fine, especially for login pages and search pages. If the clients doesn’t support it then nothing is broken… they just have to click or tab to the field manually. I also don’t mind simple authentication of form fields — the only caveat is that they must be used in conjunction with server-side authentication of fields. Of course all of this is simply an introduction to a nifty piece of javascript that I actually believe can considerably increase the ease of navigation on web pages.

<script type="text/javascript">
    function dblclick() {
    if (document.layers) {

All it does is allow you to double-click on the page anywhere (not on a link) and it will bring you to the top of the page. I haven’t checked, but you might be able to perform this action with mouse gestures in the browsers that support them (pretty much anything but IE). However this is an example of value-added javascript. As long as you can still navigate without this, I think that it adds a valuable ability.

Javascript required are not words that any self-respecting site should need to say. But hey, screw up your site… better for me.

Sept. 4, 2004 00:31 I have now added this Javascript to my main template. This page uses it, as do the archive pages, but the forum doesn’t yet.

Written by Colin Bate