标签:for pre cape size match amp bsp map result
特殊字符转义:将<, >, &, “进行转义
function escape(str){ return str.replace(/[<>"&]/g,function(match){ switch(match){ case "<": return "<"; case ">": return ">"; case "&": return "&"; case "\"": return """; } }); }
将url参数解析为json对象
function serilizeUrl(url){ var result={}; var keyvalue=[]; var key="",value=""; url=url.split("?")[1]; var map=url.split("&"); for(var i = 0, len = map.length; i < len; i++) { keyvalue=map[i].split("="); key=keyvalue[0]; value=keyvalue[1]; result[key]=value; } return result; }
标签:for pre cape size match amp bsp map result
原文地址:http://www.cnblogs.com/littlewriter/p/6789632.html