简单的Javascript Cookie操作
<mce:script type="text/javascript"><!--
function SetCookie(name,value,expire) {
var exp = new Date();
exp.setTime(exp.getTime() + expire);
document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name) {
var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name){
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}
// --></mce:script>
JavaScript Cookie封装类源码
String.prototype.format = function() {
var s = this;
for (var i = 0, j = arguments.length; i < j; i++)
s = s.replace("{" + (i) + "}", arguments[i]);
return(s);
}
var Cookie = {
Set : function () {
var name = arguments[0], value = escape(arguments[1]),
days = (arguments.length > 2) ? arguments[2] : 365,
path = (arguments.length > 3) ? arguments[3] : "/";
with(new Date()) {
setDate(getDate() + days);
days = toUTCString();
}
document.cookie = "{0}={1};expires={2};path={3}".format(name, value, days, path);
},
Get : function () {
var returnValue = document.cookie.match(new RegExp("[\b\^;]?" + arguments[0] + "=([^;]*)(?=;|\b|$)","i"));
return returnValue ? unescape(returnValue[1]) : returnValue;
},
Delete : function () {
var name = arguments[0];
document.cookie = name + "=1 ; expires=Fri, 31 Dec 1900 23:59:59 GMT;";
}
}
使用方法:
<mce:script type="text/javascript"><!--
Cookie.Set("MyCookie", "Cookie值");
Cookie.Get("MyCookie");
Cookie.Delete("
相关文档:
function testExe(entityId, wfId) {
var id = crmForm.ObjectId;
var xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http:/ ......
javascript中window对象的方法和属性资料
引用:http://www.cnblogs.com/Athrun/archive/2008/04/16/1156291.html
Window对象是客户端javascript最高层对象之一,只要打开浏览器窗口,不管该窗口中是否有打开的网页,当遇到BODY、FRAMESET或FRAME元素时,都会自动建立window对象的实例。另外,该对象的实例也可由wi ......
方法主要有三种
转换函数、强制类型转换、利用js变量弱类型转换。
1. 转换函数
js提供了parseInt()和parseFloat()两个转换函数。前者把值转换成整数,后者把值转换成浮点数。只有对String类型调用这些方法,这两个函数才能正确运行;对其他类型返回的都是NaN(Not a Number)。
在判断字符串是否是数字值前,parseInt()和 ......
在做网站的时候,我们经常需要对尺寸超标的图片进行缩放。
由于浏览器的差异,有些代码某些浏览器工作不正常。
经过研究得到了以下的代码,它可以在IE6,IE8,FireFox中完美地按比例缩放图片而不失真。
//改变图片大小
function resizepic(o)
{
var maxwidth=550; //定义最大宽度
var maxheight=800;&nbs ......