当前位置: 代码迷 >> JavaScript >> javascript escape(),encodeURI(),decodeURI(),encodeURIComponent()差异
  详细解决方案

javascript escape(),encodeURI(),decodeURI(),encodeURIComponent()差异

热度:718   发布时间:2012-10-24 14:15:58.0
javascript escape(),encodeURI(),decodeURI(),encodeURIComponent()区别

看下就明白了

原字符串:
<input name=keyword  size=100 value="http://www.yongfa365.com/"><br>
<input type=button onclick=codeurl() value="转换"><br>
encodeURI:(<font color=red>一般对网址javascript编码就用这个</font>)<input name=encodeURItest  size=100><br>
decodeURI:<input name=decodeURItest  size=100><br>
escape:<input name=escapetest  size=100><br>
encodeURIComponent:<input name=encodeURIComponenttest  size=100><br>

<script>
function codeurl()
{
encodeURItest.value = encodeURI(keyword.value)
decodeURItest.value = decodeURI(encodeURItest.value)
escapetest.value = escape(keyword.value)
encodeURIComponenttest.value = encodeURIComponent(keyword.value)
}
</script>
?
  相关解决方案