Addon JavaScript Code Snippets

These JavaScript scripts can be used in conjunction with other snippets to enhance their usefulness. These can save you a great deal of time. Many of these are generic and can be used in most snippets.

Results via Envato Market

A simple script which activates objects in Internet Explorer 7 so users don’t have to click on Flash to activate. In addition to object and embed tags, support is also provided for applet tags and all their param tags.

An easy-to-use snippet, that allows other DOM scripting to run before window.onload. The practical benefit is that JavaScript doesn’t have to wait for images or other dependencies to finish loading. It can begin as soon as the DOM is ready.

Use this snippet to determine the size of an open window. Can be used in many different situations, e.g., for setting the size of a div.

Sometimes you may want to give your visitor the URL of the page they are on. You can provide the entire path with breadcrumb scripts but, if you just want to give them the current URL, this short snippet will do the trick. Just place it anywhere on the page you want to display the URL.

Need to check Google’s new browser to see if it has a quirk that none of the other browsers have? You can detect Chrome by using this snippet in your scripts.

This script will convert entities (e.g., &, é) back into normal characters (e.g., &, xE9). Short and easy to use.

When writing many types of Web applications, there is sometimes a need to let a user delete something. It is generally a good practice, however, to have the user confirm their intentions. One method of doing this is by using a snippet of code to bring up a confirmation message. This snippet can be easily added to an existing or new script or application.

Use this snippet to let your visitors change the background color of your Web page. Combined with a cookie, the setting could follow them through your whole site.

Use this snippet to obtain the width and height of the visitor’s client window. This is a much better method than getting the resolution as this is the actual size of the window displaying the Web page.

When testing forms you don’t need to keep filling in the different fields. Use this function to automatically fill-in input blocks and select values in the form for you. Very easy to use.

Sometimes you need to display an information box. Copy this script into your document and you will have a button alert. Label it whatever you want and customize the message to fit your needs.