竟然经常遇到,但是每次都现找度娘,想想还是整理整理吧
geekwangc重点:encodeURI编码,decodeURI解码
传参页面JavaScript代码:
var url = “bad.html”;
var userName ="王超";
window.open(encodeURI(url + “?userName=” + userName)); }
接收参数页面:bad.html:
var urlinfo = window.location.href;//获取url
var userName = urlinfo.split(“?”)[1].split(“=”)[1];//拆分url得到”=”后面的参数
decodeURI(userName);
网友评论