Javascript Snippets

Strip HTML Tags from String - Remove all HTML tags from a string. If a user submits comments or other content, HTML tags need to be stripped in order control formatting.

Determine if String Contains Substring - This javascript function returns boolean true if the substring is contained in the string.

Javascript Equivalent to file_get_contents - This is a javascript function which mimics the php file_get_contents() function.

Split a String Into a 2-Dimensional-Array - Split a javascript string into a two dimensional array

Remove Quotes from String - Remove quotes from a string so it can be used in a csv file or any other situation where allowing quotes would cause the string to terminate prematurely.

Remove Return Characters From String - Remove return characters from a string. This is useful for sanitizing text which was input by a user.

Pass Javascript Variables to Another Page - Pass javascript variables from one page to another

Fade an Element In or Out with a Toggle - Fade an element in or out using a toggle button.

Determine if a Javascript Variable is a Number - Determine if a javascript variable is a numeric value.

Copy Text to Clipboard - Copy text from an input box to the clipboard.

Round Numbers Accurately to Specified Place Value with Javascript - Round numbers to a specific decimal place of accuracy.

Conditionally Load a Javascript File - Conditionally load a one or several Javascript files.

Determine When HTML Element Comes Into Viewport While Scrolling - Determine when an HTML element comes into view while scrolling.

Javascript Send Form With No Target - Send a form using Javascript which does not redirect the user. The form has no target and no callback, it just goes.

Random Shuffle Javascript Array - Shuffle a javascript array in random order.

Check for Mobile Phone - Javascript function to determine if the user is browsing with a mobile phone or not.

Shuffle a Javascript Array - This function shuffles an array in Javascript. It is only one line, and returns the shuffled array quickly.

Get the Date String in Milliseconds - Get the date in Milliseconds using Javascript cross-browser compatible.