常用JS
$_format = function (source, params) { if (arguments.length == 1) return function () { var args = $.makeArray(arguments); args.unshift(source); return $.validator.format.apply(this, args); }; if (arguments.length > 2 && params.constructor != Array) { params = $.makeArray(arguments).slice(1); } if (params.constructor != Array) { params = [params]; } $.each(params, function (i, n) { source = source.replace(new RegExp("\\{" + i + "\\}", "g"), isNull(n) ? ‘‘ : n); }); return source; };
//获取URL参数 function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return r[2]; return null; }
function FilterPasteText(str) { if (!str) { return ‘‘; } //str = str.replace(/[\n\r]/ig, ""); //remove html body form str = str.replace(/<\/?(html|body|form)(?=[\s\/>])[^>]*>/ig, ""); //remove doctype str = str.replace(/<(!DOCTYPE)([^<>])*?>/ig, ""); //remove xml tags str = str.replace(/<(\/?(\?xml(:\w+)?|xml|\w+:\w+)(?=[\s\/>]))[^>]*>/gi, ""); //remove head str = str.replace(/<head[^>]*>[\s\S]*?<\/head>/ig, ""); //remove <xxx /> str = str.replace(/<(script|style|link|title|meta|textarea|option|select|iframe|hr)[\s\S]*?\/>/ig, ""); //remove empty span str = str.replace(/<span[^>]*?><\/span>/ig, ""); //remove <xxx>...</xxx> str = str.replace(/<(head|script|style|textarea|button|select|option|iframe)[^>]*?>[\s\S]*?<\/\1>/ig, ""); str = str.replace(/<(head|script|style|textarea|button|select|option|iframe)[^>]*?>/ig, ""); //remove table and <a> tag, <img> tag,<input> tag (this can help filter unclosed tag) str = str.replace(/<\/?(a|table|tr|td|tbody|thead|th|img|input|iframe|div)[^>]*>/ig, ""); //remove bad attributes do { len = str.length; str = str.replace(/(<[a-z][^>]*\s)(?:id|name|language|type|class|on\w+|\w+:\w+)=(?:"[^"]*"|\w+)\s?/gi, "$1"); str = str.replace(/[<>]/gi, ""); } while (len != str.length); return str; }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。