function getQuery(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r!=null) return unescape(r[2]); return null;
}
alert(getQuery('actiontype'));
//取得页面名称的正则表达式
window.location.href.match(/.+//([^?]*)/)[1];
alert(window.location.href.match(///([^/?/]*)(/?|$)/)[1])
博客展示了一段JavaScript代码,定义了getQuery函数,利用正则表达式从URL中获取指定参数的值。还给出了取得页面名称的正则表达式,通过window.location.href.match方法实现。

518

被折叠的 条评论
为什么被折叠?



