chapter31

development in a land far far away…

at the moment

History is not what happened. History is what was written down.

Archive for the 'Javascript' Category

Including js files from within js files

Thursday, December 7th, 2006

I’m working on an application which stores a lot of data in the application scope. Part of the data stored is a config CFC that has a method which loads ‘external assets’ (javascript and css files etc) into the <head> of the html document via <cfhtmlhead>. I love that tag
My part in this [...]

Read the rest of this entry »

When not to use this.form.submit()

Thursday, October 12th, 2006

So ok, I’ve run into this problem in the past where I’m using an onclick event to submit a form from a button control. When you click the button you get a nice little Javascript error stating:
“this.form.submit is not a function”
Bugger…wtf?
This only seems to happen when you have a form element named “submit” already on [...]

Read the rest of this entry »

Javascript function properties

Sunday, October 1st, 2006

Javascript is pretty cool and I’ll admit that I don’t get to do as much as I’d like with it. Today I’m going to briefly cover a few properties of any Javascript function which you can take advantage of:

arguments
callee
arity

arguments
The arguments property contains an array of input parameters which may be passed to the function. It [...]

Read the rest of this entry »

Javascript parseInt() quirk

Thursday, September 28th, 2006

I ran into a little quirk or ‘bug’ today when using parseInt() with a string (input from a text box). Now as we all know parseInt() parses a string and returns an integer value.
The scenario: I was working on a legacy application where a user could pass a date to the server in 3 separate [...]

Read the rest of this entry »

Trimming strings with Javascript

Tuesday, September 19th, 2006

Ben Nadel has a nice post on trimming strings with javascript using regular expressions.
Note that the reg exp white space character ‘\s’ is used to match:

space
tab
horizontal tab
vertical tab
line break

Sample code below:

// Trims the beginning and trailing white space from a string.
function trim( strText ){
return( strText.replace(new RegExp(”^([s]+)|([s]+)$”, “gm”), “”) );
}

// Trims the beinning white space from [...]

Read the rest of this entry »