How to get #hash value in a URL in JS

前端 未结 6 1975
小蘑菇
小蘑菇 2020-12-14 18:38

For example, I have a URL as :

http://www.google.com/#hash=value2x

I want a js code to return just value2x. I tried

6条回答
  •  再見小時候
    2020-12-14 19:08

    If you are doing extensive url manipulations, then you shoud check out JQuery URL plugin.

    To access the params in url hashes

        $.url('http://www.google.com/#hfh=fdg&hash=value2x').fparam('hash');
    

    or if its current url

        $.url().fparam('hash');
    

    Hope it helps

提交回复
热议问题