zoukankan      html  css  js  c++  java
  • decodeURI()和decodeURIComponent()函数

    摘要: 本文章就是介绍两个解码的函数,他们就是decodeURI()和decodeURIComponent()函数,这两个函数可以对特定函数生成的密码字符串进行解密操作,就可以生成为未解密的字符串,比较实用,下面
    本文章就是介绍两个解码的函数,他们就是decodeURI()和decodeURIComponent()函数,这两个函数可以对特定函数生成的密码字符串进行解密操作,就可以生成为未解密的字符串,比较实用,下面来看看这两个函数的用法和实例,你就会用了:
    decodeURI()定义和用法:decodeURI() 函数可对 encodeURI() 函数编码过的URI 进行解码。
    语法:decodeURI(URIstring)
    参数 描述:URIstring 必需。一个字符串,含有要解码的 URI 或其他要解码的文本。
    返回值:URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。

    decodeURIComponent()定义和用法:decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。
    语法:decodeURIComponent(URIstring)
    参数 描述:URIstring 必需。一个字符串,含有编码 URI 组件或其他要解码的文本。
    返回值:URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。
    实例:
    [html] view plaincopy
    <html>
    <body>

    <script type="text/javascript">

    var test1="http://www.wljcz.com/My first/";
    var nn=encodeURI(test1);
    var now=decodeURI(test1);
    document.write(nn+ "<br />");
    document.write(now);

    var test1="http://www.wljcz.com/My first/";
    var bb=encodeURIComponent(test1);
    var nnow=decodeURIComponent(bb);
    document.write(bb+ "<br />");
    document.write(nnow);

    </script>

    </body>
    </html>

    其运行结果为:
    http://www.wljcz.com/My%20first/
    http://www.wljcz.com/My first/
    http%3A%2F%2Fwww.wljcz.com%2FMy%20first%2F
    http://www.wljcz.com/My first/

  • 相关阅读:
    驾照更换说明
    批处理创建快捷方式
    AC中保存数据与查询数据
    logger日志模块
    如何将python脚本转化为exe
    numpy学习
    request是个什么东西
    django的test文件的使用方式
    高频正则表达式
    dir 的作用
  • 原文地址:https://www.cnblogs.com/lizhibk/p/8623410.html
Copyright © 2011-2022 走看看