【问题标题】:Can i get the #value on the browser address bar? [duplicate]我可以在浏览器地址栏上获取#value 吗? [复制]
【发布时间】:2012-07-27 20:26:52
【问题描述】:

可能重复:
Find the “#” character in a string with Javascript
How do I get the value after hash (#) from a URL using jquery

我可以在浏览器地址栏上获取#value 吗?
例如来自 URL:http://test.com/#div1
我可以使用 javascript 从该 url 获取 div1 吗?

【问题讨论】:

  • 您给出的两个链接不是使用“#”,而是“?”在浏览器地址栏中...
  • 仅从该链接获取两行 var query = window.location.search.substring(1); var vars = query.split("&");在这里而不是 & 你可以使用 #....
  • 谢谢桑迪普,我没读好...你很棒:D

标签: javascript jquery html


【解决方案1】:

您可以使用window.location.hash

【讨论】:

  • 谢谢,但请稍等,我会测试一下... :)
  • 对不起,我会接受,但我必须等待 7 分钟... :)
猜你喜欢
  • 1970-01-01
  • 2011-04-13
  • 1970-01-01
  • 2015-03-30
  • 1970-01-01
  • 1970-01-01
  • 2018-06-02
  • 2013-02-14
  • 2018-12-02
相关资源
最近更新 更多