当前位置:网站首页>Solve the Chinese garbled code of URL in JS - decoding
Solve the Chinese garbled code of URL in JS - decoding
2022-04-23 20:24:00 【First code】
solve url The statement , There are three main ways :unescape,encodeURI as well as encodeURIComponent(), about url It contains Chinese , It was found that the previously used did not work , Changed to decodeURL Chinese decoding is normal , The code is as follows
var url = window.location.search; // obtain url in "?" The string after the sign
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
// That's the problem with this sentence
console.log( theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]));
// I used it before unescape()
// There will be garbled code
}
}
Code encapsulation reference
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); // Construct a regular expression object with target parameters
var r = window.location.search.substr(1).match(reg); // Match target parameters
if (r != null) return decodeURI(r[2]);
return null; // Return parameter value
}
getUrlParam( Parameters 1);
getUrlParam( Parameters 2);
版权声明
本文为[First code]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551267745.html
边栏推荐
- Computing the intersection of two planes in PCL point cloud processing (51)
- PCL点云处理之直线与平面的交点计算(五十三)
- redis 分布式锁
- bounding box iou
- Unity 模型整体更改材质
- Devexpress 14.1 installation record
- After route link navigation, the sub page does not display the navigation style problem
- 2022 - Data Warehouse - [time dimension table] - year, week and holiday
- Linux64Bit下安装MySQL5.6-不能修改root密码
- BMP JPEG 图片转换为矢量图像 ContourTrace
猜你喜欢
[PTA] l1-002 printing hourglass
SQL Server Connectors By Thread Pool | DTSQLServerTP 插件使用说明
A useless confession artifact
16MySQL之DCL 中 COMMIT和ROllBACK
Click an EL checkbox to select all questions
Five minutes to show you what JWT is
[stack and queue topics] - sliding window
. Ren -- the intimate artifact in the field of vertical Recruitment!
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT
Plato Farm元宇宙IEO上线四大,链上交易颇高
随机推荐
A useless confession artifact
Redis cache penetration, cache breakdown, cache avalanche
The second method of file upload in form form is implemented by fileitem class, servletfileupload class and diskfileitemfactory class.
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
WordPress插件:WP-China-Yes解决国内访问官网慢的方法
Matlab analytic hierarchy process to quickly calculate the weight
R language uses econocrats package to create microeconomic or macroeconomic map, visualize indifference function indifference curve, customize calculation intersection, and customize the parameters of
How about CICC fortune? Is it safe to open an account
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
bounding box iou
SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
上海回應“面粉官網是非法網站”:疏於運維被“黑”,警方已立案
Historical track data reading of Holux m1200-e Bluetooth GPS track recorder
XXXI` Prototype ` displays prototype properties and`__ proto__` Implicit prototype properties
R language survival package coxph function to build Cox regression model, ggrisk package ggrisk function and two_ Scatter function visualizes the risk score map of Cox regression, interprets the risk
Redis distributed lock
ABAQUS script email auto notification
BMP JPEG 图片转换为矢量图像 ContourTrace
[graph theory brush question-4] force deduction 778 Swimming in a rising pool
CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution