javascript - 获取 url uptp 所需的查询字符串 jQuery

标签 javascript jquery url query-string

考虑我的网址就像 http://localhost:4588/home?name=test&value=2003&view=current&index=1&....

我需要将 URL 带到“view”查询字符串。

这在 jQuery 中可能吗?

编辑:

url 中的前三个值单独常量(名称、值和 View ),在“ View ”之后它将发生变化。所以我只需要获取“view”查询字符串。

最佳答案

您可以使用split()分割URL:

var url = "http://localhost:4588/home?name=test&value=2003&view=current&index=1&....";
console.log(url.split('&index')[0])

说明:

url.split('&index') 将返回一个包含 2 个值的 array:

['http://localhost:4588/home?name=test&value=2003&view=current','=1&....'],这里你想要的只是第一个值(该值的索引 0 [0])。

更多关于split() .

关于javascript - 获取 url uptp 所需的查询字符串 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46724406/

相关文章:

java - java中的 "integer"相当于javascript中的什么?

javascript - Google Maps API 是否适用于 Github Pages?

javascript - Jquery toggle div with arrow animation fontawesome css

php - 如何将随机域名转换为小写一致的url?

jquery - 如何让我的 JQuery 代码识别 URL 中的参数,然后选择一行代码

javascript - 在图像加载时显示加载图标

javascript - 无法在 jquery 自动完成中获取文本框的值

javascript - 在 jQuery 中从数组动态创建参数

javascript - JQuery循环遍历多维数组

Java EE,url 中的重音,request.getParameter 值错误