encodeURI 编码 解码
encodeURI();
编码 解码都是这个方法
实例:
// 编码$(".index-search").bind('keydown',function(event){var text = encodeURI($(this).val());if(event.keyCode == "13") {window.open("search-list.html?keyword="+text);}})//解码var url = window.location.href;console.log(window.location.href);function getCaption(obj){var index=obj.lastIndexOf("\="); //获取-后边的字符串obj=obj.substring(index+1,obj.length);// console.log(obj);return obj;}var keyWord = getCaption(url);keyWord = decodeURI(keyWord);