在js字符串对象原型中添加这个获取链接参数值方法,getAddrVal(): String.prototype.getAddrVal = String.prototype.getAddrVal||function(name){ var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"); var data = this.substr(1).match(reg); return data!=null
var html = $("#summaryTemplate").html(); var imageMath = /<img [^<,>]*(?=target-type=("|')replace("|'))[^/,<,>]*\/>/; var scriptMath = /<script [^<,>]*(?=target-type=("|')replace("|'))[^/,<,>]
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } 这样调用: alert(ge
str:查询字符串: cha:查询子字符串: num:第几次出现:第一次则为 1: function findStrIndex(str, cha, num-1) { var x = str.indexOf(cha); for (var i = 0; i < num; i++) { x = str.indexOf(cha, x + 1); } return x;}
var geturl = function(url){ var ret = {}; var queryStr=url.replace(/^[^\?#]*\??/g,'').replace(/#DIALOG_.*$/g,''); queryStr.replace(/([^=&]+)=([^&]*)/g, function (a, b, c) { b = decodeURIComponent(b); c = decodeURIComponent(c); ret[b] = c; ret[b.to
function getQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i"); var r = (window.location.hash || window.location.search).substr(1).match(reg); if (r != null) return unescape(r[2]); ret
直接上函数吧 不废话 function replacestring(oldstr,newstr,text) { var exp = new RegExp(oldstr,'g'); var c=text.replace(exp,newstr); return c; } var oldstr='world'; var newstr='cccc'; var text='Hello world, Hello world'; var aa= replacestring(oldstr,newstr,tex