zoukankan      html  css  js  c++  java
  • JS中decodeURI()与decodeURIComponent()区别

    decodeURI()定义和用法:decodeURI() 函数可对 encodeURI() 函数编码过的URI 进行解码。

    语法:decodeURI(URIstring)

    参数 描述:URIstring 必需。一个字符串,含有要解码的 URI 或其他要解码的文本。

    返回值:URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。

    decodeURIComponent()定义和用法:decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码。

    语法:decodeURIComponent(URIstring)

    参数 描述:URIstring 必需。一个字符串,含有编码 URI 组件或其他要解码的文本。

    返回值:URIstring 的副本,其中的十六进制转义序列将被它们表示的字符替换。

    <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>

    关于window.location.href跳转到其他页面中文编码问题

    此href直接连接其他页面,一端用JavaScript加密另一端用JavaScript解密

    1)加密端

    encodeURI(encodeURI(String));  //String为要加密的字符串

    2)解密端

    decodeURI(String);  //String为要解密的字符串

  • 相关阅读:
    Centos配置Apache phpadmin环境
    Linux添加FTP用户并设置权限
    Java中的过滤器
    【eclipse】注释模版
    [ci db操作]
    给vmware的Linux虚拟机添加硬盘
    基于LVDS/M-LVDS的数据通信
    如何找回丢失的硬盘分区表?
    vc++怎么可以直接刷掉MBR?搞笑的吧
    EFI、UEFI、MBR、GPT的区别
  • 原文地址:https://www.cnblogs.com/shy1766IT/p/5299933.html
Copyright © 2011-2022 走看看