地址:http://localhost:12135/Hotel/HotelMappingView.aspx?city=深圳
获取js
[code=JScript]
function aa(source, name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(source)) return RegExp.$2; return "";
};
var city = aa(window.location.href, "city");
得到的参数是
%E6%B7%B1%E5%9C%B3
若何解码或者直接获取中文.?
获取js
[code=JScript]
function aa(source, name) {
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
if (reg.test(source)) return RegExp.$2; return "";
};
var city = aa(window.location.href, "city");
得到的参数是
%E6%B7%B1%E5%9C%B3
若何解码或者直接获取中文.?
解决方案 »
- jQuery如何让多个效果一起执行
- 请高手解决一下下啊 。。。。 多谢!!!!
- javascript中如何取得文本框控件的背景颜色
- window.showModalDialog有permission denied错误,急求!!!
- 帮忙 很简单的截取字符串问题
- 为什么 5.1*100不是510
- 请问如何抓到google map中的javascript脚本?
- var mywin=window.open错误提示mywin不是对象的问题。
- 请教:javaScript中的变量能传给本页的java变量吗?
- checkbox问题
- 诡异!javascript alert乱码。。。
- 个人做个在线的网站真难啊。。。
document.write(decodeURI("%E6%B7%B1%E5%9C%B3"));
</script>结果:深圳
是这个方法。
decodeURIComponent() 或者 decodeURI 解码
decodeURI() 函数可对 encodeURI() 函数编码过的URI 进行解码
decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码
encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z