Site Archives javascript
JAVASCRIPT: The start of a jQuery zoom event handler
After much research and very little code, I’ve come up with a basic start to a jQuery zoom event handler. Don’t laugh. This is very basic, but it handles zoom events based on keyboard shortcuts and fires the handler.
JAVASCRIPT: Simple date conversion from SQL to readable
I needed a simple date converter function from SQL dates (YYYY-MM-DD) to something readable (M/D/YYYY). So I wrote this little function. Maybe someone else will have some use for it.
1
2
3
var makeSQLDatePretty = function(d) {
return d.replace(/([0-9]{4})-0?([0-9]{1,2})-0?([0-9]{1,2})/, ‘$2/$3/$1′);
};
Pass in a SQL date and the function trims leading zeros and returns a reformatted date.
1
2
var sqlDate = [...]
JAVASCRIPT: Smart, unobtrusive AJAX form submission with jQuery
A former coworker was telling me recently about MooTools and how the AJAX functions are so easy to use. He sent me the following example:
JAVASCRIPT: Iterating through objects, the easy way
Objects in any ECMAScript language (Javascript, Actionscript, Jscript, etc) are very powerful for - among other things - storing data. However, getting some information out of these objects can be a hassle sometimes.
I ran into this issue recently and wrote some cool little handlers for objects. The following methods can be used to [...]
JAVASCRIPT: onerror image magic
HTML has a little-known event handler for <img> and <body> tags. I’m going to focus on <img> tags and how you can use this to clean up some 404s.
JAVASCRIPT: Internet Explorer’s attachEvent breaks ‘this’
First of all, let me just say that I love jQuery. It makes Javascript development so much faster. I’m sure that Prototype is just as easy for those that use that daily, but I prefer jQuery. And before you ask… Yes, I learned both.
That having been said, there are some applications where [...]
JAVASCRIPT: Method overloading
John Resig, one of my heroes and creator of the jQuery JavaScript library, wrote a great piece about overloading methods. He created a dead simple function that shoulders most of the work. Check it out:
1
2
3
4
5
6
7
8
9
function addMethod(object, name, fn){
var old = object[ name ];
object[ name ] = function(){
[...]
JAVASCRIPT: Creating objects and methods
That’s right, object-oriented Javascript. Let’s get to it. We’re going to make an object for storing and retrieving user information.
Let’s start with the base object:
1
2
var User = function(firstName, lastName, emailAddress) {
}
We have to initialize the variables so that they’re available to the rest of the methods of this object:
1
2
3
4
5
var User = function(firstName, lastName, [...]
Find It Quickly
Find what you're looking for quickly by using our keyword search. Can't find it? Try our links below.