Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

JavaScript trim()

String.prototype.trim = function () {
return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

//
written by Douglas Crockford

JavaScript delete confirmation

function confirmDelete(msg,loc)
{
if( confirm(msg) )
{
location.href = loc;
}
}

or

function confirmDelete(message)
{
return confirm(message);
}