Category Archive
for: ‘Javascript’

Launch Fancybox automatically

Fancybox currently does not directly support a way to automatically launch. The work around I was able to get working is creating a hidden anchor tag and triggering it’s onclick event. Make sure your call to trigger the onclick event is included after the jquery and fancybox js files are included. The code I used [...]

Read More

Decode HTML entities with jQuery

Decoding HTML entities can be so easy with jQuery. The following code snippet converts all HTML entities to their applicable characters:

Read More

Cross Domain Iframe Height Resize

If you try to set an iframe height which is hosted in another domain, the browser might throw security exception. So here is my solution to get it work in every browser based on the cross-domain jQuery postMessage Plugin.

Read More

Javascript Location Hash

Bookmark hash “#” sign provides the functionality to target thenamed anchor HTML <a> tag within the same other web pages. When you click on any link text that targets the bookmarked location of any webpage it adds the “#” symbol and bookmark name to the end of the URL. You can place the location.hash or [...]

Read More

Measuring time with Javascript

If you need to measure how long something takes with Javascript you can use the Date() object to get a start timestamp and then compare it later on using a second Date() object. Although I’m sure there are other benchmarking plugins etc available this can be a quick and easy way to benchmark something in [...]

Read More

Javascript: isArray Function

This is a little tutorial of how to check a variable to know if it’s an array in JavaScript. Unfortunately there’s no built-in “isArray” function like there is with other languages (such as php is_array). And, to make matters worse, strings are really arrays of characters. So checking value[0] can give you a valid value [...]

Read More

JavaScript: trim function

For whatever reason JavaScript doesn’t include a trim method natively. This means that one of the first tasks for anyone doing any type of string processing (especially form validation) in JavaScript is to write a trim() method (or use a framework that provides one). The two following functions are supposed to be very fast: 1 [...]

Read More

jQuery: Animated Scroll to Top

The following Javascript will change all <a href=”#top”> links to scroll to the top instead of the instant jump that normally happens when the link is clicked. Note the “return false;” line. This is required otherwise the default action will be done and the instant scroll will happen instead of the nice animated scrolling effect.

Read More

Javascript: Time Ago (fuzzy Time)

Twitter, Facebook, Gmail, and all the big guns are using the fuzzy date/time of type “3 minutes ago”, “10 days ago”, “last month” etc. The following Javascipt function makes it easy to support such fuzzy timestamps.

Read More

Javascript: Inserting Thousand Separators

This post contains a simple JavaScript function for numerical formatting. It formats decimal numbers by inserting separator characters at the thousands positions. For example, 1234512345.12345 becomes 1,234,512,345.12345. You can also specify other separator and decimal point characters to suit your culture.

Read More
Page 1 of 3123»
 
© 2010 onYou GmbH. All Rights Reserved