获取转义的 URL 参数 [英] Get escaped URL parameter

查看:31
本文介绍了获取转义的 URL 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个 jQuery 插件,它可以获取 URL 参数,并且支持这个搜索字符串而不输出 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:

æøå

(字符是挪威语).

我无权访问服务器,因此无法对其进行任何修改.

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;
//=> æøå

这篇关于获取转义的 URL 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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