使用 JavaScript 解析 URL 哈希/片段标识符 [英] Parsing URL hash/fragment identifier with JavaScript

查看:39
本文介绍了使用 JavaScript 解析 URL 哈希/片段标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

寻找一种使用 JavaScript/JQuery 将 URL 的哈希/片段中的键对解析为对象/关联数组的方法

Looking for a way to parse key pairs out of the hash/fragment of a URL into an object/associative array with JavaScript/JQuery

推荐答案

查看:jQuery BBQ

jQuery BBQ 旨在解析来自 url(查询字符串或片段)的内容,并进一步简化基于片段的历史记录.这是 Yarin 在组装纯 js 解决方案之前一直在寻找的 jQuery 插件.具体来说, deparam.fragment() 函数完成这项工作.看看!

jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look!

(我正在使用的支持站点使用异步搜索,并且因为 BBQ 使得将整个对象放入片段中变得微不足道,所以我使用它来保留"我的搜索参数.这为我的用户提供了他们搜索的历史状态,还允许他们为有用的搜索添加书签.最重要的是,当 QA 发现搜索缺陷时,他们可以直接链接到有问题的结果!)

(The support site I'm working on uses an asynchronous search, and because BBQ makes it trivial to tuck entire objects into the fragment I use it to 'persist' my search parameters. This gives my users history states for their searches, and also allows them to bookmark useful searches. Best of all, when QA finds a search defect they can link straight to the problematic results!)

这篇关于使用 JavaScript 解析 URL 哈希/片段标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆