js几种escape()解码与unescape()编码

服务器端:

  Server.UrlEncode()方法对Url进行编码

  Server.UrlDecode()方法 对url进行解码

Js方法:

  escape() 函数可对字符串进行编码;

  unescape() 函数可对字符串进行解码;

定义和用法

unescape() 函数可对通过 escape() 编码的字符串进行解码。

定义和用法

escape() 函数可对字符串进行编码,这样就可以在所有的计算机上读取该字符串。

简单例子:

js编码:

 1 Var name= escape ($(“#txtname”).value());
 2 var strurl =login.aspx+ "?opt=add&companyname=" + name ;
 3   $.ajax({
 4         type: "POST",
 5         cache: true,
 6         url: strurl,
 7         data: "opt=skip",
 8         success: function (json) {
 9            //成功方法
10         },
11         error: function (e) { }
12     });

解码:服务器端的解码简单:

 1 String name= Server.UrlDecode(Request.QueryString["companyname "].ToString()); 

原文地址:https://www.cnblogs.com/lgx5/p/15180544.html