//页面跳转
window.location.href = "地址?param=" + encodeURIComponent(param);
//encodeURIComponent对参数进行编码,防止传值过程中文乱码
//也可使用encodeURI编码,注意encodeURI需要对整条url编码
//接收url,读取参数值
var url = document.location.href;
var param;
if(url.indexOf("?") != -1){
var index = url.lastIndexOf("?param=");
param= decodeURIComponent(url.substring(index + 7, url.length));
}
//decodeURIComponent对参数进行解码
//如果使用encodeURI编码,则使用decodeURI解码
JS 页面跳转与值传递(解决url传参中文乱码问题)
最新推荐文章于 2024-05-11 08:35:15 发布