Learn how to create a slideshow using JavaScript. It will feature next, previous, play, pause and resume buttons along with transition effects between pictures. First let’s create the HTML elements that we will use for the slideshow. We need an image, four buttons and two divs: We will use the img tag to display the pictures in […]
Disable The Firebug Plugin
Using JavaScript, you can disable the Firebug Firefox plugin to prevent others from debugging your code. This JavaScript code snippet is designed to ensure that the console object exists in the browser environment, even in browsers where it might not be natively supported or if certain tools like Firebug are not present. Here’s a breakdown: […]
Trim Leading And Trailing Spaces
Trim the whitespaces at the beginning and end of a string using while loops instead of regular expressions.
Convert a number from digits to words
A JavaScript function for converting numbers (21) to words (twenty-one). It works for numbers up to 999, but it can be transformed to support numbers in the thousands too.
Check URL validity using JavaScript
The CheckValidUrl() function takes in an URL and checks whether or not it is valid by verifying it against a regular expression. Works for HTTP, HTTPS and FTP URLs.
Submit form on selection of dropdown item
This example code addresses a popular need to have a form submitted on the selection of a value from a dropdown control.
Get window width and height
Get the window width and height in JavaScript using a cross-browser function that works with all versions of Internet Explorer and Firefox.
Verify the version of Internet Explorer being used
Using JavaScript, this function verifies if the current version of Internet Explorer is the same one as the one passed through the function argument.
How to pop up the Print dialog from a web page
You can very easily pop up the Print dialog using a JavaScript call to a function. The following code works in all major browsers, including Internet Explorer and Firefox:
How to improve the performance of your for loops
Instead of the typical: Use: Because instead of checking the length of the array each loop and comparing it to i, it stores it in a variable arrLen, which is then compared at each loop with i. This saves a few milliseconds, since checking the array length requires slightly more processing power.