html1:

<!DOCTYPE HTML>

<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>test</title> <a href="2.htm" v="任晓强" id="test">go</a> <style>
.cur{color:#f00;}
</style> <script>
test.href = test.href + "?" + encodeURIComponent(test.getAttribute("v"));//对任晓强进行编码 </script>

html2:

<!DOCTYPE HTML>

<meta charset=utf-8>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>test</title> <div id="test"></div> <style>
.cur{color:#f00;}
</style> <script>
var name = decodeURIComponent(location.search).replace("?",""); //解码并替换网址 //decodeURIComponent(name); console.log(name) test.innerHTML = "你好" + name; //给test赋值
</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. Java Concurrency - wait & notify, 等待通知机制

    生产者消费者问题是一个常见的多线程同步案例:一组生产者线程和一组消费者线程共享一个初始状态为空.大小为 N 的缓冲区.只有当缓冲区没满的时候,生产者才能把消息放入缓冲区,否则必须等待:只有缓冲区不空的 ...

  2. Commons CLI - Option Properties

    Option Properties The following are the properties that each Option has. All of these can be set usi ...

  3. Cocos2d-x使用UserDefault数据持久化实例:保存背景音乐和音效设置

    UserDefault可以实现数据的存储,但是它的使用不能泛滥,具体讲一般情况下不会使用它保存大量的数据,它没有SQL语句那样的灵活.UserDefault除了保存游戏设置外,还有可以长期保持游戏精灵 ...

  4. iOS开发——开发者官网注册新设备

    1.第一步登陆苹果开发者中心官网,进入证书栏后如下图:点击All 或者如果是iPhone设备直接点击iPhone也行. 然后点击右上角的[+]号

  5. OC3-父类指针指向子类对象

    // // Cat.h // OC3-父类指针指向子类对象 // // Created by qianfeng on 15/6/17. // Copyright (c) 2015年 qianfeng. ...

  6. UvaLive7362 Fare(欧拉函数)

    题意:求1~n的素因子之和. 分析:欧拉函数 #include<cstdio> #include<cstring> #include<cctype> #includ ...

  7. GTEST-ASSERT出错

    ASSERT_TRUE(1==1); ASSERT_EQ(1,1); 会给出以下错误: "cfunctest_normal.cpp", line 121.9: 1540-0258 ...

  8. OD常用断点

    OD常用断点 很全很全 常用断点 拦截窗口: bp CreateWindow 创建窗口 bp CreateWindowEx(A) 创建窗口 bp ShowWindow 显示窗口 bp UpdateWi ...

  9. String inputStream file转化

    String --> InputStreamByteArrayInputStream stream = new ByteArrayInputStream(str.getBytes()); Inp ...

  10. asp.net导出Excel 按照预定格式,以及解决导出乱码

    protected void ToExcel() { //新建一个Gridview,原因:避免当前窗口GridView外层没有直接跟form标签,从而避免“gridview1未包含在run='serv ...