当前位置:网站首页>js 获取url参数并且进行中文解析
js 获取url参数并且进行中文解析
2022-06-09 05:43:00 【加蓓努力我先飞】
function getQuery() {
let href = window.location.href//获取url
href = decodeURI(href);//使用 decodeURI() 对一个编码后的 URI 进行解码:
let query = href.substring(href.indexOf('?') + 1);//获取?后面的参数部分
let param = query.split("&");//将参数部分-用&分割,转换成数组
let obj = {
}
for (var i = 0; i < param.length; i++) {
let per = param[i].split("=");//将数组中的每一项-用=分割,转换成数组
obj[per[0]] = per[1]//以键值对的形式储存
}
return obj;
}
var querys = getQuery();
console.log("querys", querys)//获得的参数
边栏推荐
- Swagger basic use quick start
- MySQL one master multi slave configuration centos7 pro test
- Practical guide to GStreamer application development (I)
- Yolov5-6.0系列 | yolov5的模型网络构建
- IP address division and subnet
- 对pyqt5和SQL Server数据库进行连接
- Swift 协议
- Heqibao's trip to Chongqing ~
- Yolov5-6.0 series | yolov5 model network construction
- Yolov5-6.0系列 | yolov5的模块设计
猜你喜欢

Two methods of unbutu installing ffmpeg

MySQL add field or create table SQL statement

Several implementation methods of redis distributed lock

SET DECIMAL_V2=FALSE及UDF ERROR: Cannot divide decimal by zero及Incompatible return types DECIMAL问题排查

Yolov5-6.0系列 | yolov5的模块设计

冒泡排序,打印菱形,打印直角三角形,打印倒三角,打印等边三角形,打印九九乘法表

Interview process and thread

Gstreamer应用开发实战指南(四)

Deque of STL

数据血缘用例与扩展实践
随机推荐
SQL optimization notes - forward
matlab----多项式、函数
XML建模
Record TCP time once_ Blood cases caused by wait
latex中\cdots后面接上句子,后面的句子格式会乱怎么回事。
Alibaba cloud AI training camp -sql basics 6: test questions
Synchronized detailed parsing
lambda匿名函数
Two methods of unbutu installing ffmpeg
Alibaba cloud AI training camp - SQL basics 4: set operation - addition and subtraction of tables, join, etc
arthas-boot
Remove duplicates from sort array -leetcode
使用MAT进行内存问题定位
三大队列cxq,entrylist,waitset 个人理解分析
[it] Foxit PDF retention tool selection
Analysis of the most complete webrtc server technology selection in history
Topic24——3. 无重复字符的最长子串
How to monitor JVM GC
Fundamentals of deep learning: face based common expression recognition (2) - data acquisition and collation
AspNetPager combines stored procedure paging to speed up access