encodeURIComponent()编码和decodeURIComponent()解码
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()解码的更多相关文章
- 浏览器URL中 encodeURIComponent()加密和decodeURIComponent()解码
encodeURIComponent()加密 定义和用法 encodeURIComponent() 函数可把字符串作为 URI 组件进行编码. 语法 encodeURIComponent(URIstr ...
- encodeURIComponent编码java后台解码出现乱码问题
问题:JavaScript请求后台带着name参数,有中文进行编码:url?name=" + encodeURIComponent(name):java后台直接使用name或者name=ja ...
- encodeURIComponent()加密、decodeURIComponent()解码及v-html将字符串转换为html
1)新闻详情页后台给我的数据是加密之后的,我问了后台,是用encodeURIComponent()加密的,然后我就用对应的方法decodeURIComponent()解密: this.$store.s ...
- encodeURIComponent编码后java后台的解码 (AJAX中文解决方案)
encodeURIComponent编码后java后台的解码 (AJAX中文解决方案) 同学的毕业设计出现JavaScript用encodeURIComponentt编码后无法再后台解码的问题. 原来 ...
- JS escape、encodeURI 、encodeURIComponent 编码与解码[转]
转至:http://jc-dreaming.iteye.com/blog/1702407 本文讨论如何对传递参数用JS编码与解码 1:编码与解码方法的对应关系 escape ------------- ...
- encodeURIComponent编码2次
最近在项目中发现前台在往anction中发送数据时进行两次encodeURIComponent,经过上网查找发现以下解释比较合理,mask过来,以供参考,非常感谢原作者!!! 两次encodeURIC ...
- encodeURI,encodeURIComponent编码
encodeURI().encodeURIComponent().decodeURI().decodeURIComponent() URL编码 Global对象的encodeURI()和encodeU ...
- encodeURIComponent编码时为什么要编码两次
Why 要对url进行编码? 当使用地址栏提交查询参数时,如果不编码,非英文字符会按照操作系统的字符集进行编码提交到服务器,服务器会按照配置的字符集进行解码,所以如果两者不一致就会导致乱码. Wh ...
- encodeURIComponent编码反斜杠 \ (正则匹配)
记录一个小bug... 前言废话: 1. 功能需求:修改输入框的内容,获取字符串传给后端保存. 2. bug历程:刚开始直接获取value值传过去.后来测试发现%&这些特殊字符无法传递后,在前 ...
- WebRTC VideoEngine超详细教程(三)——集成X264编码和ffmpeg解码
转自:http://blog.csdn.net/nonmarking/article/details/47958395 本系列目前共三篇文章,后续还会更新 WebRTC VideoEngine超详细教 ...
随机推荐
- Quartz Scheduler(2.2.1) - Usage of CronTriggers
Cron is a UNIX tool that has been around for a long time, so its scheduling capabilities are powerfu ...
- MVC下用户登录状态校验的问题以及解决方案--------------Action全局过滤器的使用
前言当我们访问某个网站的时候需要检测用户是否已经登录(通过Session是否为null),我们知道在WebForm中可以定义一个BasePage类让他继承System.Web.UI.Page,重写它的 ...
- Android应用中-更新提示显示红点的方案
什么是红点更新提示? 红点更新提示类似微信朋友圈有新的朋友消息 时会在“发现”tab上显示红点,表示有新的消息. 目前三种显示方式: 1.显示具体数字 2.只显示红点 3.显示省略,表示数量很多 方案 ...
- 实现iOS项目一款用swift实现的应用top源码
Top 后台 Swift版本Ios 8 / iPhone 5S适配这边有个登陆,如果你们想测试的话,可以用这个账号, 账号:18868879362 密码:420562 源码下载: http://c ...
- Cocos2d-x实例:单点触摸事件
addChild(boxC,30, kBoxC_Tag); ...
- PHP学习笔记 - 入门篇(2)
PHP入门篇(2) 什么是变量 变量是用于存储值的容器,如下 $var = @"6666" 如何定义变量 定义变量就是像服务器的内存申请空间,用来存储数据,eg: <?php ...
- springMVC+Hibernate常用的配置文件
每次写一个新的web项目时都要写配置文件.比较麻烦,现在把常用到的配置文件记录下来,方便以后使用 web.xml <?xml version="1.0" encoding=& ...
- 九度OJ 1541 二叉树【数据结构】
题目地址:http://ac.jobdu.com/problem.php?pid=1541 题目描述: 旋转是二叉树的基本操作,我们可以对任意一个存在父亲节点的子节点进行旋转,包括如下几种形式(设被旋 ...
- Ubuntu Android Studio/IntelliJ IDEA 支持文件中文命名
Android Studio 默认字体无法使用中文命名文件,中文显示空心方块,使用思源字体,可解析 下载思源字体http://www.cnblogs.com/icgq/p/4195347.html 选 ...
- CSS3 弹性盒布局模型(转)
简介 引入弹性盒布局模型的目的是提供一种更加有效的方式来对一个容器中的条目进行排列. 对齐和分配空白空间.即便容器中条目的尺寸未知或是动态变化的,弹性盒布局模型也能正常的工作.在该布局模型中,容器会根 ...