Home >php教程 >php手册 >javascript取URL值的方法

javascript取URL值的方法

WBOY
WBOYOriginal
2016-06-06 20:00:56913browse

location.href='ping.html#chen=陈建平' 取锚点值 location.hash 结果是:#chen=陈建平 location.href='ping.html?chen=陈建平' 取?后面的值 location.href.search() 结果是:?chen=陈建平 再用substring(1) 就可以取#或?后的值了,再用split()方法可以把

location.href='ping.html#chen=陈建平'


取锚点值  location.hash  结果是:#chen=陈建平



location.href='ping.html?chen=陈建平'


取?后面的值  location.href.search() 结果是:?chen=陈建平


再用substring(1)  就可以取#或?后的值了,再用split()方法可以把多个参数放入数据中


var args=xx.split('&') 

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