美文网首页
JS工作笔记

JS工作笔记

作者: 大话家丶 | 来源:发表于2017-05-09 17:35 被阅读0次

js实现禁用浏览器后退####

2017年5月9日
利用js实现 禁用浏览器后退


前台请求后台返回的json字符串中含有html标签####

2017年5月10日15:44:05
当前台请求后台返回的字符串中包含HTML和Javascript代码的时候会出现解析错误,这时可以在字符串保存的时候使用encodeURIComponent()函数把字符串作为 URI 进行编码。前台请求使用的时候再用decodeURIComponent()函数解码。

<script type="text/javascript">
  var test = "<html><body></body></html>";
  var test1 = encodeURIComponent(test);
  console.log(test1);
  console.log(decodeURIComponent(test1));
</script>
%3Chtml%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E
<html><body></body></html>

相关文章

网友评论

      本文标题:JS工作笔记

      本文链接:https://www.haomeiwen.com/subject/duritxtx.html