1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > 利用location.href跳转页面传值(中文) 乱码问题

利用location.href跳转页面传值(中文) 乱码问题

时间:2021-05-31 12:11:01

相关推荐

利用location.href跳转页面传值(中文) 乱码问题

之前做了一个博客跳转页面,用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);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。