JS Encode and Decode URL
2016-02-25 14:11
686 查看
1.Encode URL String
2.Decode URL String
3.HTML URL Endoding References
测试网址:http://www.w3schools.com/tags/ref_urlencode.asp
原文网址:http://www.sitepoint.com/jquery-decode-url-string/
var url = $(location).attr('href'); //get current url //OR var url = 'folder/index.html?param=#23dd&noob=yes'; //or specify one var encodedUrl = encodeURIComponent(url); console.log(encodedUrl); //outputs folder%2Findex.html%3Fparam%3D%2323dd%26noob%3Dyes
2.Decode URL String
var url = $(location).attr('href'); //get current url //OR var url = 'folder%2Findex.html%3Fparam%3D%2323dd%26noob%3Dyes'; //or specify one var decodedUrl = decodeURIComponent(url); console.log(decodedUrl); //outputs folder/index.html?param=#23dd&noob=yes
3.HTML URL Endoding References
space %20 ! %21 " %22 # %23 $ %24 % %25 & %26 ' %27 ( %28 ) %29 * %2A + %2B , %2C - %2D . %2E / %2F ... etc
测试网址:http://www.w3schools.com/tags/ref_urlencode.asp
原文网址:http://www.sitepoint.com/jquery-decode-url-string/
相关文章推荐
- JS备忘--子父页面获取元素属性、显示时间,iframe之间互相调用函数
- js的单线程
- javascript的变量声明提升
- 灵活的理解JavaScript中的this指向
- 【bzoj1030】[JSOI2007]文本生成器 trie图DP
- javascript文件中引用依赖的js文件的方法
- javascript设置和获取cookie的通用方法
- JavaScript 事件——“事件类型”中“复合事件”和“变动事件”的注意要点(转)
- js 字符串 函数
- js this作用域问题讲解
- three.js加载obj模型
- javascript Date format(js日期格式化) (转)
- EL-JSTL表达式
- js中使用new Date(str)创建时间对象不兼容firefox和ie的解决方式
- 13.4 javascript事件类型
- getjson时使用random= Math.random 解决数据缓存问题
- Js实现浏览器下标签页间切换触发的事件
- jsp详细说明
- Js 内各种宽度
- 该如何理解AMD ,CMD,CommonJS规范--javascript模块化加载学习总结