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

This snippet is a function that validates a URL. It can easily be added to your current validation script.

Unequal column heights make CSS layouts difficult to manage when the height of content cannot be known in advance, particularly in scenarios where absolute positioning is in use. While there are a variety of strategies to deal with this issue, here’s a jQuery-based fix.

Many times you just want a popup window to stay open for a few seconds, or a bit longer. Place this snippet in the body tag of the popup window.

Use this script to ensure that a user can only reach a given page from another specified page. Easy to set-up and use.

Object detection is common in JavaScript. Browser irregularities mean that your code must sometimes contain branches for different browsers. Use this snippet to perform object detection once instead of every time you call addEvent.

Usually, when one event loads, it writes over any previous ones. Using this snippet, you can add several events to one page without any problems.

You can remove existing nodes using the DOM. The removeChild method allows any node to remove one of its child nodes. Simply pass a reference to the node you wish to remove. Any text or elements within the node being removed will be removed along with it.

This is a simple, cross-browser method for testing for pop-up blockers. Most scripts test the return value of and conclude that there is a blocker installed if the returned value resolves to false in a boolean statement. However, these scripts fail with browsers such as Opera (as of v9) that return a window object but disable it. This script properly handles this, as well as a null or undefined return type.

Use this snippet to detect if the client browser is using a popup blocker. If a one is detected, the script can then perform a different action. The sample uses an alert box to inform the user whether a popup blocker is present or not.