获取转义的网址参数 [英] Get escaped URL parameter
问题描述
我正在寻找一个可以获取URL参数的jQuery插件,并支持此搜索字符串而不输出JavaScript错误:格式错误的URI序列。如果没有支持这个的jQuery插件,我需要知道如何修改它来支持这个。
I'm looking for a jQuery plugin that can get URL parameters, and support this search string without outputting the JavaScript error: "malformed URI sequence". If there isn't a jQuery plugin that supports this, I need to know how to modify it to support this.
?search=%E6%F8%E5
解码后,URL参数的值应为:
The value of the URL parameter, when decoded, should be:
æøå
(这些字符是挪威语。)
(the characters are Norwegian).
我无权访问服务器,因此我无法修改任何内容。
I don't have access to the server, so I can't modify anything on it.
推荐答案
你不应该像这样使用jQuery!
现代的方法是使用通过像Bower这样的包管理器的小型可重用模块。
You should not use jQuery for something like this!
The modern way is to use small reusable modules through a package-manager like Bower.
我创建了一个小的模块可以将查询字符串解析为对象。像这样使用它:
I've created a tiny module that can parse the query string into an object. Use it like this:
// parse the query string into an object and get the property
queryString.parse(unescape(location.search)).search;
//=> æøå
这篇关于获取转义的网址参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!