1.Encode 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 Encode and Decode URL的更多相关文章

  1. 用node.js写个在Bash上对字符串进行Base64或URL的encode和decode脚本

    一:自己这段时间经常要用到Base64编码和URL编码,写个编译型语言有点麻烦干脆就用node.js弄了个,弄好后在/etc/profile里加上alias就能完成工具的配置,先上代码: functi ...

  2. [LeetCode] Encode and Decode TinyURL 编码和解码精简URL地址

    Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL sho ...

  3. 535. Encode and Decode TinyURL 长短URL

    [抄题]: TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problem ...

  4. 535 Encode and Decode TinyURL 编码和解码精简URL地址

    详见:https://leetcode.com/problems/encode-and-decode-tinyurl/description/ C++: class Solution { public ...

  5. 011_如何decode url及图片转为base64文本编码总结

    一.咱们经常会遇到浏览器给encode后的url,如何转换成咱们都能识别的url呢?很简单,talk is easy,Please show me your code,如下所示: (1)英文decod ...

  6. Encode and Decode TinyURL

    TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/desi ...

  7. Leetcode: Encode and Decode TinyURL

    Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL sho ...

  8. 【Leetcode】535. Encode and Decode TinyURL

    Question: TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/pro ...

  9. 535. Encode and Decode TinyURL(rand and srand)

    Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL sho ...

随机推荐

  1. [转载] COM 套间

    http://www.vckbase.com/index.php/wv/1315 简序 大学毕业前的最后一学期,在一家公司实习,当时的工作需要用到一些操作系统提供的组件.那时候只知道COM这个名词,并 ...

  2. 百度地图API 定位一直4.9E-324

    使用百度地图Android SDK 7.0定位坐标一直为4.9E-324,网上搜索了很多,但是均未解决我的问题,在此坐下解决记录,在设置权限中将应用添加信任即可!android 6.0 其他版本未测! ...

  3. java 静态代码块 构造块 构造方法

    class className{ static{ }//静态代码块 { }//构造代码块 public className(){} //构造方法 }

  4. jQuery学习笔记(控件位置定位、尺寸大小的获取等)

    想做一个幽灵按钮出来,效果大概如下图: 当点击按钮的时候,会有四根线条从四个方向飞入,经历从“无-有-无”的闪入过程. 那么我的设计想法是,先在HTML中定义一个按钮,然后在jQuery中设计按钮点击 ...

  5. Debian7下lnmp+gunicorn部署Django运行环境

    首先安装lnmp,安装方法见lnmp.org wget -c http://soft.vpser.net/lnmp/lnmp1.3-full.tar.gz && tar zxf lnm ...

  6. AspNetPager分页控件

    AspNetPager分页控件解决了分页中的很多问题,直接采用该控件进行分页处理,会将繁琐的分页工作变得简单化,下面是我如何使用AspNetPager控件进行分页处理的详细代码:1.首先到www.we ...

  7. Runtime Reconfiguration

    https://coreos.com/etcd/docs/latest/runtime-configuration.html Runtime Reconfiguration  运行时重新配置 etcd ...

  8. 关于搭建一个高性能网站的服务器的架设思路以及nginx测试的并发

    对于高性能网站的架设,主要就是请求量大,那我们该如何进行支撑? 考虑到下面的几个方面: 1.要减少请求,那对于开发人员来说,网站的css文件进行合并,背景图片也要合并,一般都是请求一张比较大的图片,然 ...

  9. MySQL的高可用设计方案的记录

    一.看下常用的MySQL的高可用方案: 对上图的说明: 1)HeartBeat通过串口线或者以太网网线直连网卡对对端的服务做健康检查,并负责执行Drbd,MySQL,vip等资源的自动切换. 2)da ...

  10. C# windows form如何隐藏窗口?

    you can use this line of code. It wont hide it, but it will be minimized: this.WindowState = FormWin ...