• 2023-08-21当字符串中含有%,先使用 encodeURI 进行编码,再使用decodeURI解码报错
    报错原因:decodeURI不允许参数有%,它会自动把%25转义为%,这个转义后的%导致的报错解决方法一在解码decodeURI之前将%替换为%25编码:url=encodeURI(encodeURI(url));解码:url=url.replaceAll("%","%25");url=decodeURI(decodeURI(url));解决方法二在编码encodeURI之前就将%
  • 2023-06-01前端页面之间url传参
    functiongetUrlParam(name){varreg=newRegExp("(^|&)"+name+"=([^&]*)(&|$)");varr=window.location.search.substr(1).match(reg);//ECMAScriptv3已从标准中删除了unescape()函数,并反对使用它,因此应该用decodeURI
  • 2022-12-21复习js小知识点之decodeURIComponent与decodeURI
    临近年底了,最近有了点空闲的时间,所以复习了一下js今天看到书上介绍了encodeURIComponent与encodeURI的区别,区别主要如下1、encodeURI只会编码空格,用%20代替,而而encodeURI
  • 2022-11-23JavaScript decodeURI() 函数 Url 解码
    定义和用法decodeURI()函数可对encodeURI()函数编码过的URI进行解码。语法decodeURI(URIstring)参数描述URIstring必需。一个字符串,含有要解码的URI或其他要解码
  • 2022-09-20var url = decodeURI(location.search)涉及到的知识点
    https://www.runoob.com/jsref/prop-loc-search.html1、location.search返回URL的查询部分。假设当前的URL就是http://www.runoob.com/submit.htm?email=someone@exampl