Javascript

Pass variable to javascript use javascript

Client wants add following tracking code on website: To ensure accurate tracking, they want [CACHEBUSTER] can be replaced by a Time Stamp when page reload. This is the way we use:

How to use the W3C Geolocation API

Introduction Imagine visiting a city for the first time. You're hungry, but don't know where the nearest restaurants are and which of them are any good. Wouldn't it be nice if some app could detect your location and provide you with a list of restaurants closest to you, along with reviews and ratings for each one? And this is not the only consideration — could it detect your location accurately, keeping in mind your privacy as well? This is where the W3C Geolocation API comes in, suppo...

Javascript trim function

In programming, trim is a string manipulation function or algorithm. The most popular variants of the trim function strip only the beginning or end of the string. Typically named ltrim and rtrim respectively. This Javascript code trim implementation removes all leading and trailing occurrences of a set of characters specified. If no characters are specified it will trim whitespace characters from the beginning or end or both of the string. Without the second parameter, Javascript function ...

Free download javascript slideshow

Download javascript slideshow here

Javascript Equivalent of PHP’s trim function

Trim function in PHP can remove whitespace from the beginning and end of a string. Javascript do not have this function, but is easy to made one.

Javascript Equivalent of PHP’s explode() and implode()

Do you know javascript has equivalent functions as php's explode() and implode(). Let's say we have a string: We want to break down each number into an array called $num_array. In PHP we could do this: The PHP implode function would produce the following: In Javascript, we can use split function. Then let's say we wanted to piece it back into the original string. We could just do this in php: $string = implode(':',$explode_array); In Javascript, we c...

How to add bookmark javascript in IE and Firefox

Adding the "bookmark this page" javascript below will help to encourage return visits. Your visitor simply clicks on the link and a popup prompt will appear so they can add your site to their favorites list.

How to Display Alexa Traffic Rank Statistics at Your Website

Following codes will display different statistics graphs / charts on your web page. Replace 'yoursite' with your 'domain name' to use these. Alexa traffic ranks graphs and charts for google.com look like these:

Useful Javascript Code

This function will remove any characters or punctuation which is not allowed in input.