之前做了一個博客跳轉頁面,用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);