Category Archives: JavaScript

Star Wars Crawl

· 14 Comments · in HTML5, JavaScript

Star Wars CrawlThis is my homage to the original “Star Wars” in HTML5, CSS and JavaScript.

It’s coded to run on an iPhone but viewable in the latest versions of Firefox, Safari and Chrome. You can also view on an iPad or iTouch. But not in IE.

Uses a combination of HTML5, CSS animation and JavaScript.

Slice a query string and store as object values using JavaScript

· 75 Comments · in JavaScript

I recently had a need to reuse query string values multiple times on a page.

Calling a function that parses the query string each time just isn’t efficient.

I decided to use a self-executing function I wrote that stores the values as properties of an object.


Using jQuery to loop thru DOM objects with optional delay

· 13 Comments · in JavaScript, jQuery

You want to loop through a collection of DOM objects, so you use .each().

But what if you want to have a delay between effects on the current item?

In short – don’t use .each() for looping – and don’t use setTimeout for the delay.

We’re going to call items by index instead, optionally using a clever way to add a delay.

Allowing an iframe to manipulate itself on same domain using only JavaScript

· 4 Comments · in JavaScript

Ok, this one I wrote is kinda cool. :)

I was working on a large corporate site that had iframes all over the place.

They had internal content(same domain) that would show up inside these iframes.

jQuery and JavaScript snippets

· 1 Comment · in JavaScript, jQuery

This is a list of useful snippets that do not garner their own posts.

The jQuery snippets have been tested with version 1.7.2+.

If you have any to contribute, email them to me and I will post them!

Load an external stylesheet using JavaScript

· 7 Comments · in CSS, JavaScript

There are times when you may not want to load a CSS file on page load, especially if it is a large file.

You can load that external file using only JavaScript.

Here’s how…

Pausing an animation with jQuery

· Leave a comment · in JavaScript, jQuery

Starting an animation with jQuery is easy.

Stopping an animation with jQuery is easy.

But what if we want to “pause” and restart the animation?

Well, not so easy – so I dug in and figured a way to make this work cross-browser.

Background animation using jQuery

· 3 Comments · in JavaScript, jQuery

You can actually animate a background image with jQuery – though it’s not as easy as it sounds.

There are cross-browser concerns.

I’ve tested many ways to achieve it and in this post there is code that should work cross-browser. Let’s dig in…

Creating a namespace in JavaScript

· Leave a comment · in JavaScript

If you don’t namespace your code – you should.

It not only encloses the code but also gives it a unique name for reference.

This avoids “code collision”, where two like named objects or functions can break your code.

JavaScript logging in console and window

· 1 Comment · in JavaScript

I recently had the need to add logging to a real-time application using JavaScript.

Most developers usually throw in console.log or alerts during development. But if the consoles/alerts are not removed before code goes to production or a client, it can cause a big problem.

The following code example using console.warn provides this safely. If window.console or console.warn are not supported, no message is generated. But it does not cause the page to choke, like using a simple console.log.