[javascript] view plain copy function turnto(){ var getval=document.getElementById("text").value; turngetval=escape(getval); document.location.href="search.html?a="+turngetval; } 上面这段代码的意思是从本html中获取input中输入的内容,然后变url的值,实现跳转到第二个页面 第二个页面中 [javascript] view plain copy var thisURL = document.URL; var getval =thisURL.split('?')[1]; var showval= getval.split("=")[1]; //keyword=showval; keyword=unescape(showval); 这个就是根据url来获取前一个html中传过来的值 要注意上面两段代码中的 [javascript] view plain copy turngetval=escape(getval); 和 [javascript] view plain copy keyword=unescape(showval); 这两句是对传出的值进行一个改变编码,防止传值的时候传的是汉字。 在url中是不能传汉字的,虽然我们看见的是汉字,但是浏览器把他们根据utf8或gb2312对他们转化为编码等等; 编码变化较多,各个浏览器的编码也不一样,所以我们就在进入url之前,就按照已知的编码规则对汉字进行一个转化编码。 然后通过url传就没有问题了。 传过去之后再解析得到汉字即可。