日期:2014-05-16  浏览次数:20339 次

常用的js函数处理
/**
* Return a string with &, < and > replaced with their entities
*/
function escapeHtml(original) {
  return original.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#039;');
};

/**
* Replace common XML entities with characters
*/
function unescapeHtml(original) {
  return original.replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&amp;/g,'&');
};
/*
* Trim() function
*/
String.prototype.Trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}

String.prototype.LTrim = function(){
return this.replace(/(^\s*)/g, "");
}

String.prototype.RTrim = function(){
return this.replace(/(\s*$)/g, "");
}