html1:

  1. <!DOCTYPE HTML>
  2.  
  3. <meta charset=utf-8>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <title>test</title>
  6.  
  7. <a href="2.htm" v="任晓强" id="test">go</a>
  8.  
  9. <style>
  10. .cur{color:#f00;}
  11. </style>
  12.  
  13. <script>
  14. test.href = test.href + "?" + encodeURIComponent(test.getAttribute("v"));//对任晓强进行编码
  15.  
  16. </script>

html2:

  1. <!DOCTYPE HTML>
  2.  
  3. <meta charset=utf-8>
  4. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  5. <title>test</title>
  6.  
  7. <div id="test"></div>
  8.  
  9. <style>
  10. .cur{color:#f00;}
  11. </style>
  12.  
  13. <script>
  14. var name = decodeURIComponent(location.search).replace("?",""); //解码并替换网址
  15.  
  16. //decodeURIComponent(name);
  17.  
  18. console.log(name)
  19.  
  20. test.innerHTML = "你好" + name; //给test赋值
  21. </script>

encodeURIComponent()编码和decodeURIComponent()解码的更多相关文章

  1. 浏览器URL中 encodeURIComponent()加密和decodeURIComponent()解码

    encodeURIComponent()加密 定义和用法 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码. 语法 encodeURIComponent(URIstr ...

  2. encodeURIComponent编码java后台解码出现乱码问题

    问题:JavaScript请求后台带着name参数,有中文进行编码:url?name=" + encodeURIComponent(name):java后台直接使用name或者name=ja ...

  3. encodeURIComponent()加密、decodeURIComponent()解码及v-html将字符串转换为html

    1)新闻详情页后台给我的数据是加密之后的,我问了后台,是用encodeURIComponent()加密的,然后我就用对应的方法decodeURIComponent()解密: this.$store.s ...

  4. encodeURIComponent编码后java后台的解码 (AJAX中文解决方案)

    encodeURIComponent编码后java后台的解码 (AJAX中文解决方案) 同学的毕业设计出现JavaScript用encodeURIComponentt编码后无法再后台解码的问题. 原来 ...

  5. JS escape、encodeURI 、encodeURIComponent 编码与解码[转]

    转至:http://jc-dreaming.iteye.com/blog/1702407 本文讨论如何对传递参数用JS编码与解码 1:编码与解码方法的对应关系 escape ------------- ...

  6. encodeURIComponent编码2次

    最近在项目中发现前台在往anction中发送数据时进行两次encodeURIComponent,经过上网查找发现以下解释比较合理,mask过来,以供参考,非常感谢原作者!!! 两次encodeURIC ...

  7. encodeURI,encodeURIComponent编码

    encodeURI().encodeURIComponent().decodeURI().decodeURIComponent() URL编码 Global对象的encodeURI()和encodeU ...

  8. encodeURIComponent编码时为什么要编码两次

    Why 要对url进行编码? 当使用地址栏提交查询参数时,如果不编码,非英文字符会按照操作系统的字符集进行编码提交到服务器,服务器会按照配置的字符集进行解码,所以如果两者不一致就会导致乱码.   Wh ...

  9. encodeURIComponent编码反斜杠 \ (正则匹配)

    记录一个小bug... 前言废话: 1. 功能需求:修改输入框的内容,获取字符串传给后端保存. 2. bug历程:刚开始直接获取value值传过去.后来测试发现%&这些特殊字符无法传递后,在前 ...

  10. WebRTC VideoEngine超详细教程(三)——集成X264编码和ffmpeg解码

    转自:http://blog.csdn.net/nonmarking/article/details/47958395 本系列目前共三篇文章,后续还会更新 WebRTC VideoEngine超详细教 ...

随机推荐

  1. AndroidStudio KeyMap

  2. oracle 所有下级

    --所有下级 SELECT SAP_ORGAN_CODE FROM SAP_ORGAN_LEVEL CONNECT BY PRIOR SAP_FATHER_ORGAN_CODE= SAP_ORGAN_ ...

  3. [转]WCF 4 安全性和 WIF 简介

      转自:http://www.cnblogs.com/WizardWu/archive/2010/10/04/1841793.html 本帖简介 .NET 新一代的 Windows Identity ...

  4. 改变UITextField placeHolder 字体 颜色

    [_textSearchField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"]; ...

  5. jquery学习全面总结

    本文仅针对jquery的部分知识点做总结,更为全面的可以去官网看中文文档.可以更为详细的了解jquery及其特性. window.onload 和$(document).ready() 我 windo ...

  6. opencv 手写选择题阅卷 (一)表格设计与识别

    (一)答题表格设计与识别 实际设计好的表格如下图 为了图像精确,表格和四角的标记都是由程序生成的,文字和数据是后期排版软件添加上去的. 图中四角的四个黑方块主要用来定位表格,然后就可以切割出每个单元格 ...

  7. [ZZ+CH] Html5 canvas+js 时钟

    总之新Blog入驻以后,又开始老习惯,到处折腾自定义的空间,放些东西. 想起以前大一的时候做过一个Javascript的时间显示器,现在想做一个时钟,当然现在老奸巨猾,会先去看一看有前辈写过没. 前辈 ...

  8. 视酷即时通讯系统应用源码 V1.0

    视酷即时通讯系统(原创),成熟稳定,拥有和微信一样强大的功能不再是梦,节省几个月研发时间迅速融合进项目中: 1.首家支持聊天室群聊 2.支持和微信一样的语音聊天,可以显示时长.未读状态,自动轮播未读语 ...

  9. C++ 读取 pcap文件.

    http://blog.csdn.net/haolipengzhanshen/article/details/51854853 1.了解下pcap文件的结构 2.定义pcap文件头部结构体pcapFi ...

  10. Setfocus - IE 需要使用setTimeout

    setTimeout(function () { $('#controlid').focus(); }, 100); document.getElementById('filterPopupInput ...