Category: Javascript

Example scripts and howtos for Javascript

Javascript is a programming or scripting language primarily used for client-sided programming in web browsers. It can also be used as a server-side programming language but this is generally used less often. Javascript was originally created by Netscape for their browser Netscape Navigator, and is now an implementation of the ECMAScript standard. It is typically used in web browsers for form validation, floating navigation, AJAX and other nifty things to make web pages more interactive.

Load JSON data with jQuery

JSON data can be retrieved using AJAX from a server either using jQuery’s .ajax() function or the shorthand $.getJSON() function. If you have retrieved a JSON string without having jQuery decode it automatically using one of these functions, the string can also be parsed into a regular data array using the $.parseJSON() function.

Read More »

Get an element’s position relative to the document with jQuery

jQuery’s .offset() method returns an offset containing the top and left co-ordinates of the element top-left position relative to the document as a whole. There’s is also a .position() method which is supposed to return the offset relative to the offset parent but for me it always returns the same co-ordinates as .offset(). Maybe I’m doing something wrong with .position()…

Read More »

Detecting the browser engine and version with jQuery

While you ideally shouldn’t use browser detection to choose whether or not to render something in a particular fashion, jQuery does provide the capability to work out which browser renderingengine and version is being used with $.browser. There is also $.support which provides information about what the rendering engine supports and I will look at that in a later post.

Read More »

Google Analytics Asynchronous Tracking

Google recently released updated tracking code for Google Analytics which allows for asynchronous tracking. This means the analytics tracking can be done at the same time as rendering other content and therefore won’t delay other page content from rendering. This results in what appears to be faster rendering pages.

Read More »