Home > php教程 > php手册 > body text

javascript取URL值的方法

WBOY
Release: 2016-06-06 20:00:56
Original
866 people have browsed it

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('&') 

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!