Home  >  Article  >  Web Front-end  >  js分解url参数(面向对象-极简主义法应用)_javascript技巧

js分解url参数(面向对象-极简主义法应用)_javascript技巧

WBOY
WBOYOriginal
2016-05-16 17:51:031083browse

修改前:

复制代码 代码如下:



修改后:
复制代码 代码如下:



感谢 草根程序猿很厉害把这个方法重写了一下,更严密,高效了,最后面在些再学习一下!!!
复制代码 代码如下:



注:
1、substr()与substring(start,stop) ,提取字符串中介于两个指定下标之间的字符。
重要事项:与 slice() 和 substr() 方法不同的是,substring() 不接受负的参数。
参见http://www.jb51.net/w3school/js/jsref_substring.htm
2、location.search.substring(1) ,location.search设置或返回从问号 (?) 开始的 URL(查询部分)。
参见http://www.jb51.net/w3school/htmldom/prop_loc_search.htm
3、exec() 方法用于检索字符串中的正则表达式的匹配。太强大了,还不会用
参考http://www.jb51.net/w3school/js/jsref_exec_regexp.htm
4、使用 decodeURIComponent() 对编码后的 URI 进行解码。
参见http://www.jb51.net/w3school/js/jsref_exec_regexp.htm
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn