JS (JQuery)对Html、URL的编码解码

  首先引入JQuery文件

  1、js对Html编码

function htmlEncode(value){
  return $('<div/>').text(value).html();
}

  2、js对Html解码

function htmlDecode(value){
  return $('<div/>').html(value).text();
}

  3、js对Url编码

function urlEncode(value){
  return encodeURIComponent(value);
}

  4、js对Url解码

function urlDecode(value){
  return decodeURIComponent(value);  
}

 

C#对Html、URL的编码与解码


Server.HtmlEncode(str); //Html编码
Server.HtmlDecode(str); //Html解码

Server.UrlEncode(str); //URL编码
Server.UrlDecode(str); //URL解码
 

 

相关文章:

  • 2021-11-17
  • 2022-02-22
  • 2021-09-12
猜你喜欢
  • 2022-12-23
  • 2021-09-30
  • 2021-06-13
  • 2021-10-15
  • 2021-12-01
  • 2021-09-21
相关资源
相似解决方案