【问题标题】:Extracting the query from the URL从 URL 中提取查询
【发布时间】:2012-03-31 12:56:39
【问题描述】:

如何使用 Javascript 或 Jquery 从 URL 中获取参数值更简单!

我得到了这个网址

 http://website.in/instant/#mystring

我想要

 mystring

仅来自 URL 的 # 之后的字符串

【问题讨论】:

    标签: javascript jquery url


    【解决方案1】:

    window.location.hash 返回带有“#”的哈希,因此您可以使用:window.location.hash.substr(1)

    【讨论】:

    • window.location.hash.replace('#','') 更安全,因为一些较旧的浏览器(我认为是 IE
    【解决方案2】:

    你想要window.location.hash

    【讨论】:

    • 我知道!但是如何从查询中提取确切的字符串?
    • @NarendraRajput:我看到你到处都有答案。只需在需要数据的地方执行“window.location.hash”即可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 2012-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多