兼容火狐,ie8的 js urlencode和urldecode
function UrlEncode(str)//url编码
{
var i,temp,p,q;
var result="";
for(i=0;i<str.length;i++)
{
temp = str.charCodeAt(i);
if(temp>=0x4e00)
{
execScript("ascCode=hex(asc(\""+str.charAt(i)+"\"))", "vbscript");
result+=ascCode.replace(/(.{ 2 })/g, "%$1");
}else{
result+=escape(str.charAt(i));
}
}
return result;
}
function UrlDecode( str )
{
var i,temp;
var result = "";
for( i=0; i<str.length; i++ )
{
if( str.charAt(i) == "%" )
{
if( str.charAt(++i) == "u" )
{
temp = str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i++) + str.charAt(i);
result += unescape("%" + temp);
}
else
{
temp = str.charAt(i++) + str.charAt(i);
if( eval("0x"+temp) <= 160 )
{
result += unescape( "%" + temp );
}
else
{
temp += str.charAt(++i) + str.charAt(++i) + str.charAt(++i);
result += Decode_unit("%" + temp);
}
}
}
else
{
result += str.charAt(i);
}
}
return result;
}
最新文章
- 程序员必须要知道的Hadoop的一些事实
- SQL Server 2014新特性探秘(2)-SSD Buffer Pool Extension
- Windows 双网卡指定网络出口
- ArcGIS Engine中数据的加载 (转)
- HashSet、LinkedHashSet、TreeSet
- Tools Function
- Visual studio 2013安装及单元测试
- MySQL定时检查是否宕机并邮件通知
- 稀疏表示(sparse representation)和字典学习
- Xposed知识
- Nginx+Keepalived 做负载均衡器
- Oracle 10g体系结构及安全管理
- 位运算,算术、逻辑运算详解-java篇
- 解决mysql连接报“Communications link failure”错误
- bootstrap 常用class
- Hive简单编程实践-词频统计
- Git学习之连接GitHub远程仓库
- java方法重载和重写
- LeetCode - 767. Reorganize String
- jq初入行常用动画
热门文章
- Unity3d通用工具类之NGUI图集分解
- 嵌入式linux GUI--DirectFB + GTK至尊秘笈
- 共享锁&;排它锁 || 乐观锁&;悲观索
- Informatica 常用组件Filter之一 概述
- WF4.0(3)----变量与参数
- kafka基本原理概述——patition与replication分配
- HDU 2825 Wireless Password【AC自动机+DP】
- IIS7.5配置Asp.net项目出现HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。
- 【Python】得到当前日期时间
- JavaScript高级程序设计(第3版)学习笔记&#183;第8章——浏览器对象模型BOM