URL编码和解码工具
2015-08-19 17:28
281 查看
开发中发现需要进行URL的编解码,每次百度出来的还带广告而且比较慢,写了一个本地的工具,比较简单,希望对大家有帮助。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <!-- Author: Kang, Leo Date: 2015-8-19 Email: kangyi@staff.weibo.com QQ: 531155260 --> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <style type="text/css"> textarea{ height:200px; width:100%; margin:5px; } input{ height:40px; width:100%; margin:5px; background:#00CED1} .button2{ height:40px; width:100%; margin:5px; background:#00FF7F} </style> </head> <body> <script type="text/javascript"> function funDecode(){ var url = document.getElementById("url_input").value; document.getElementById("url_decoded_input").value = decodeURIComponent(url.replace(/\+/g, " ")); } function funEncode(){ var url = document.getElementById("url_decoded_input").value; document.getElementById("url_encode_input").value = encodeURIComponent(url).replace(/'/g,"%27").replace(/"/g,"%22"); } </script> <form name="myForm"> <h4>需要解码的URL:</h4> <textarea id="url_input" name="input" rows="14" maxlength="32768"></textarea> <br /> <input type="button" name="urlDecodeInput" value="点击开始URL解码" onclick="funDecode()" /> <br /> <h4>解码后的URL或者待编码的URL:</h4> <textarea id="url_decoded_input" name="input" rows="14" maxlength="32768"></textarea> </form> <form name="myForm"> <input type="button" name="urlEncodeButton" class="button2" value="点击开始URL编码" onclick="funEncode()" /> <br /> <h4>编码后的URL:</h4> <textarea id="url_encode_input" name="input" rows="14" maxlength="32768"></textarea> </form> </body> </html>
相关文章推荐
- 提高php编程效率技巧
- Ceph性能调优——Journal与tcmalloc
- HDOJ 2680 Choose the best route (最短路之SPFA)
- 2015-8-19数据结构学习-哈夫曼树
- TCP 的那些事儿(上)
- servlet设置缓存时间以及文件的下载
- 设计模式之Strategy模式
- 背包之01背包、完全背包、多重背包详解
- Android开发必知--WebView加载html5实现炫酷引导页面
- SQL Server类型与C#类型对应关系
- Java HttpClient
- bzoj3436
- 当一个数据库插入事务由于错误被回滚时,被插入表中标识字段的值该发生怎么样的变化?
- Torch7 Serialization
- 一致性选择
- Deep Learning(深度学习)学习笔记整理系列
- 【原】iOS:手把手教你发布代码到CocoaPods(Trunk方式)
- Introduction to Java Programming编程题3.22<判断点是否在圆内>
- 快速排序
- 【Android】 Android存储之 sharedpreferences (用户偏好设置)