You are viewing all articles posted in “Javascript”

Recent articles can be found on the homepage.

Guessing font availability with Javascript

posted on 13 November 2008 (09:28 PM)

Recently I wanted to use an uncommon font in a website, but the site was too image-rich to use sIFR, (loading time made for an uneasy user experience).

I decided to add the font anyway in my stylesheet, and provide a “lo-fi” experience, for people who didn’t have the font handy.

The lo-fi version however, should mimic the style of the uncommon font as good as possible.

Sometimes, though, that’s easier said than done.

Read more

Making the most of Javascript namespacing

posted on 29 October 2008 (05:33 PM)

Today's article by Robert Nyman about Javascript namespacing remembered me about my own approach, which I've been using for quite a few projects now.

If you have no clue about Javascript namespacing, go and read Robert's article. I'll wait.

Read more

Focus onload but keep Backspace intact

posted on 12 September 2008 (05:26 PM)

A lot of websites try to help you by auto-focusing on an input field on pageload, so you can start typing right away.

Well, thanks so much, you guys couldn't be more helpful.
Except of course that I always use the Backspace key to move back in my history. By focusing on a form field you're essentially disabling some fundamental browser functionality.

Read more

Dynamically added form elements lose their margins

posted on 08 September 2008 (11:17 AM)

I stumbled upon an annoying bug today. When dynamically appending input fields to the DOM, their margins are not as you specified in their respective classes.

Read more

Subcookies V2

posted on 09 May 2008 (02:47 PM)

My Subcookies article from May the 27th of last year has proven to be my most popular bit of writing.

A year after publishing, "C" has requested an update.

I have now rewritten my cookies script, fixing some issues pointed out by "C", and added some security as pointed out by Jim Thomson.

Read more

Javascript Periodical Executer

posted on 03 August 2007 (03:46 PM)

When writing Javascript, you sometimes want to execute a certain function repeatedly (for instance, when creating a bit of animation, or when pinging for new messages in an AJAX chat application).

This involves calls to setTimeout or setInterval and usually repeatedly checking some conditions.

For simple, periodically executed calls to your custom functions, I have now written an easy extension to the Function prototype.

Read more

Be careful when fetching width!

posted on 26 July 2007 (12:04 AM)

I stumbled across a little oddity today. It kept me busy for longer than I would've liked, so I thought I'd share (although you're probably not very likely to run into the problem, since it's not a very common situation).

Read more

Javascript function return values

posted on 03 July 2007 (03:05 PM)

This thread on Sitepoint today made clear to me that not everyone understands how return values work in Javascript. I decided to write up an explanation.

Read more

Take your cookies to the next level with Subcookies

posted on 27 May 2007 (01:30 AM)

Cookies provide an easy way to save some user data. They can be a nice aid in usability, as they give you a way of remembering certain choices made by the user.

Browsers have placed some restrictions on the storage capacity of a cookie, though. They usually allow only 20 cookies to be stored per domain or server. To circumvent this problem, I'll explain a technique called "subcookies" to you and show you an easy Javascript way of accessing the so-called subcookies.

The article has been down for a day, unfortunately, due to a PHP error. I'm terribly sorry! The article is fixed now, do check it out :)

Read more

Animated lists: Graceful degradation using CSS 3

posted on 01 May 2007 (07:25 PM)

I like to think of creative ways to provide graceful degradation; If Javascript is disabled, is there a CSS way to use the features Javascript would provide?. Most of the time, the answer, sadly, is "No".

With CSS 3 however, it's a lot easier to provide gimmicky stuff without having to write Javascript, and therefore, it's easier to provide graceful degradation. Note: the example in this article will only work in browsers that support (parts of) the CSS 3 spec, such as Firefox.

Read more

A quick note on unobtrusive Javascript

posted on 01 March 2007 (12:49 PM)

For Javascript to work truely unobtrusive, a webpage should remain usable at all times. This means that a page should work if:

  • Javascript is enabled
  • Javascript is disabled
  • The required Javascript function is unavailable

Read more

Simplify function arguments

posted on 30 January 2007 (01:10 PM)

Sometimes functions ask for a lot of arguments (or parameters). Even when using functions you've written yourself, it's sometimes hard to keep track of the order in which the arguments are expected.

In this article I will explain a technique that makes argument-order redundant and might make your programming life easier.

Read more

Vfields: Variable length input fields

posted on 13 December 2006 (02:37 PM)

Personally, I don't like it when the data I submit in an online form exceeds the input field I'm typing in.

It's annoying when half of your text gets cut off by the edge of the field. So today, I thought of a way to (perhaps) make input fields more usable.

Read more

Altering JavascriptFlashGateway

posted on 10 September 2006 (03:34 PM)

In my current project, some communication between Javascript and Actionscript is needed. While a couple of years ago, this was hard to achieve and relied on unstable techniques that were not very cross-browser compatible, Macromedia made a developer's life a little easier by introducing the JavascriptFlashGateway.

Read more

Image popups that fit

posted on 23 August 2006 (02:19 PM)

First of all; popup windows should not be used. They're annoying, unfriendly thingies that should only be used as a last resort. Jakob Nielsen even states it the number 2 Web Design Mistake in his Top Ten. So don't use 'em! There are much better alternatives anyway. But if you really, really want to use popups, this article provides you with a handy approach.

Read more


These settings will be saved for your convenience.