JS 转码 编码

<script type="text/javascript">
function test_encodeURI(){
alert(encodeURI('你是')); // 到jsp页面中解码的话用URLDecoder.decode即可,具体参看类URLEncodeTest.java
document.write(encodeURI('你是')+"<br>");
alert(decodeURI('%E4%BD%A0%E6%98%AF')); // encodeURIComponent
document.write(encodeURI('www.cup.edu.cn')+"<br>");
document.write(encodeURIComponent('http://www.cup.edu.cn')+"<br>");    //http%3A%2F%2Fwww.cup.edu.cn
document.write(decodeURI('www.cup.edu.cn')+"<br>");
document.write(decodeURIComponent('http%3A%2F%2Fwww.cup.edu.cn')+"<br>");   //http://www.cup.edu.cn
}
</script>

你可能感兴趣的:(js,script,转码,encodeURI)