Javascript String对象扩展HTML编码和解码的方法

时间:2009-06-02    点击:92   
复制代码 代码如下:

String.prototype.HTMLEncode = function() {
var temp = document.createElement ("div");
(temp.textContent != null) ? (temp.textContent = this) : (temp.innerText = this);
var output = temp.innerHTML;
temp = null;
return output;
}

String.prototype.HTMLDecode = function() {
var temp = document.createElement("div");
temp.innerHTML = this;
var output = temp.innerText || temp.textContent;
temp = null;
return output;
}
JavaScript效率调优经验
cookie丢失问题(认证失效) Authentication (用户验证信息)也会丢失
javascript 常用方法总结
Javascript 获取字符串字节数的多种方法
javascript HTMLEncode HTMLDecode的完整实例(兼容ie和火狐)
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved