之前做了一个博客跳转页面,用onclick事件响应跳转到编辑页面时,出现乱码,解决办法用encodeURI()进行编码,
用decodeURI() 函数对encodeURI() 函数编码过的 URI 进行解码。
第一个页面:
window.location.href = "editBlog.html?title=" + encodeURI(obj.title) +
"&tag=" + encodeURI(currentTag.id) + "&content=" + encodeURI(obj.content) + "&id=" +encodeURI(obj.id) ;
第二个编辑页面取值:
var search = decodeURI(location.search);
本文介绍了一个使用URI编码解决页面跳转时出现乱码的问题。通过encodeURI()对参数进行编码,并在目标页面使用decodeURI()解码,确保了数据正确传递。
2806

被折叠的 条评论
为什么被折叠?



