String Searching in Javascript

New Javascript developers frequently ask how to search for a string within another string using Javascript. The indexOf method is what you are looking for and is available on String and Array objects. String.indexOf(searchValue) returns the index of (hence the name) the first match OR -1 if the value was not found, it does not …

Firing asynchronous quantcast pixels

If you are building an AJAX-driven web application (like a swipe-driven mobile website) and want to register quantcast pageviews at times other than window.onload, here is a small change to the code snippet quantcast provides that will get you there. Note that this does not remove or replace any existing functionality, you will still need …

Check client language with Javascript

It is simple enough to detect the end-users preferred language: var language = window.navigator.userLanguage || window.navigator.language; This will be a country code, for example ‘it’ or ‘en-US’ Example This particular example uses the Google Translate service and will trigger the translate widget to show up if their language is different from your target language: [raw] …