<iframe marginwidth="0" marginheight="0" src="http://218.16.120.35:65001/PC/Global/images/b.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>
1
/**//*------------------------------------------------------------
2
*S.SamsLifexperience
3
*CopyRight(C)2003-2007S.SamsLifexperienceScriptClassLib
4
*MSNLive:S.Sams#msn.com
5
*Http://blog.8see.net/
6
*UPdateby:2007-01-19转载传播请保留版权
7
*-----------------------------------------------------------*/
8
9
10
/**//*$获取指定对象
11
@element对象名
12
可以使用对象名集合,返回值为对象的集合
13
如果您使用了Prototype类库,请把该函数注释掉
14
Sams_object.Get()中同样实现该函数的所有功能
15
*/
16
function$(element)
{
17
if(arguments.length>1)
{
18
for(vari=0,elements=[],length=arguments.length;i<length;i++)
19
elements.push($(arguments[i]));
20
returnelements;
21
}
22
if(typeofelement=='string')
23
element=document.getElementById(element);
24
returnelement;
25
}
26
27
///浏览器相关操作
28
varSams_browse=
{
29
/**//*检测浏览信息*/
30
checkBrowser:function()
31

{
32
this.ver=navigator.appVersion
33
this.dom=document.getElementById?1:0
34
this.ie6=(this.ver.indexOf("MSIE6")>-1&&this.dom)?1:0;
35
this.ie5=(this.ver.indexOf("MSIE5")>-1&&this.dom)?1:0;
36
this.ie4=(document.all&&!this.dom)?1:0;
37
this.ns5=(this.dom&&parseInt(this.ver)>=5)?1:0;
38
this.ns4=(document.layers&&!this.dom)?1:0;
39
this.mac=(this.ver.indexOf('Mac')>-1)?1:0;
40
this.ope=(navigator.userAgent.indexOf('Opera')>-1);
41
this.ie=(this.ie6||this.ie5||this.ie4)
42
this.ns=(this.ns4||this.ns5)
43
this.bw=(this.ie6||this.ie5||this.ie4||this.ns5||this.ns4||this.mac||this.ope)
44
this.nbw=(!this.bw)
45
returnthis;
46
},
47
48
/**//*设为首页
49
@url要设为首页的地址
50
*/
51
SetDefault:function()
52

{
53
this.style.behavior='url(#default#homepage)';
54
this.setHomePage(this.GetUrl());
55
returnfalse;
56
},
57
58
/**//*复制指定URL地址
59
@Msg要写入剪贴板的字符集
60
*/
61
SetCopy:function(Msg)
{
62
if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{
63
clipboardData.setData('Text',Msg);
64
alert("网址“"+Msg+"”/n已经复制到您的剪贴板中/n您可以使用Ctrl+V快捷键粘贴到需要的地方");
65
}
66
else
67

{
68
prompt("请复制网站地址:",Msg);
69
}
70
},
71
72
/**//*加入收藏
73
@site站点名称
74
@url地址
75
*/
76
AddBookmark:function(site,url)
{
77
if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{
78
window.external.addFavorite(url,site)
79
}elseif(navigator.userAgent.toLowerCase().indexOf('opera')>-1)
{
80
alert("请使用Ctrl+T将本页加入收藏夹");
81
}else
{
82
alert("请使用Ctrl+D将本页加入收藏夹");
83
}
84
},
85
86
/**//*打开Url指定宽度和高度的窗口*/
87
OpenWindows:function(url,width,height)
88

{
89
window.open(url,'newwin','width='+width+',height='+height);
90
returnfalse;
91
},
92
93
/**//*禁止浏览器的Javascript错误提示*/
94
CloseError:function()
{
95
window.onerror=function()
{returntrue;};
96
},
97
98
/**//*获取浏览器URL*/
99
GetUrl:function()
{
100
returnlocation.href;
101
},
102
103
/**//*获取URL参数*/
104
GetUrlParam:function()
{
105
returnlocation.search;
106
},
107
108
/**//*获取页面来源*/
109
GetFrom:function()
{
110
returndocument.referrer;
111
},
112
113
/**//*获取指定的URL参数值
114
@name参数名
115
*/
116
Request:function(name)
{
117
varGetUrl=this.GetUrl();
118
varPlist=newArray();
119
if(GetUrl.indexOf('?')>0)
120

{
121
Plist=GetUrl.split('?')[1].split('&');
122
}
123
elseif(GetUrl.indexOf('#')>0)
124

{
125
Plist=GetUrl.split('#')[1].split('&');
126
}
127
if(GetUrl.length>0)
128

{
129
for(vari=0;i<Plist.length;i++)
130

{
131
varGetValue=Plist[i].split('=');
132
if(GetValue[0].toUpperCase()==name.toUpperCase())
133

{
134
returnGetValue[1];
135
break;
136
}
137
}
138
return;
139
}
140
},
141
142
/**//*直接将HTML写到新窗口
143
@title标题
144
@msg内容
145
*/
146
Popmsg:functionPopIt(title,msg)
147

{
148
varpopup=window.open('','popDialog','height=500,width=400,scrollbars=yes');
149
popup.document.write('<html><title>'+title+'</title><style>body
{margin:10px;font:13pxArial;}span
{text-line:20px;}</style><body><spanstyle=/'font:14pxarial;/'>'+msg+'</span></body></html>');
150
popup.document.close();
151
}
152
};
153
154
155
///对象操作
156
varSams_object=
{
157
158
/**//*创建一个DIV对象
159
@ID要创建的对象ID
160
@ClassName创建对象的Class
161
@SetValue设置该对象值
162
@ToDiv将对象追加到指定的对象,如指定的对象不存在,则追加在Body的后面
163
返回创建后的对象
164
*/
165
CreateDiv:function(ID,ClassName,SetValue,ToDiv)
{
166
varcreatediv=document.createElement('div');
167
if(ID!=null)creatediv.id=ID;
168
creatediv.style.position='absolute';
169
if(ClassName!=null)creatediv.className=ClassName;
170
if(this.Get(ToDiv))
171

{
172
this.Get(ToDiv).appendChild(creatediv);
173
}
174
else
175

{
176
document.getElementsByTagName('body')[0].appendChild(creatediv);
177
}
178
this.SetValue(ID,SetValue);
179
returnthis.Get(ID);
180
},
181
182
/**//*删除指定DIV对象
183
@objid要删除的对象ID
184
返回Bool操作结果
185
*/
186
DeleteDiv:function(objid)
187

{
188
try
189

{
190
if(this.Get(objid))
191

{
192
varGetParent=this.Get(objid).parentNode;
193
GetParent.removeChild(this.Get(objid));
194
returntrue;
195
}
196
else
197

{
198
returnfalse;
199
}
200
}
201
catch(e)
202

{
203
returnfalse;
204
}
205
},
206
207
/**//*获取浏览器对象
208
@id要获取的对象ID
209
可以使用对象名集合,返回值为对象的集合
210
*/
211
Get:function(objid)
{
212
if(arguments.length>1)
{
213
for(vari=0,objids=[],length=arguments.length;i<length;i++)
214
objids.push(this.Get(arguments[i]));
215
returnobjids;
216
}
217
if(typeofobjid=='string')
218

{
219
if(document.getElementById)
{
220
objid=document.getElementById(objid);
221
}elseif(document.all)
{
222
objid=document.all[objid];
223
}elseif(document.layers)
{
224
objid=document.layers[objid];
225
}
226
}
227
returnobjid;
228
},
229
230
/**//*获取对象的值
231
@objid对象ID
232
*/
233
GetValue:function(objid)
{
234
if(typeofobjid=='string')
235

{
236
vargetTagName=this.Get(objid).tagName.toLowerCase();
237
if(getTagName=='input'||getTagName=='textarea'||getTagName=='select')
238

{
239
returnthis.Get(objid).value;
240
}
241
elseif(getTagName=='div'||getTagName=='span')
242

{
243
returnthis.Get(objid).innerText;
244
}
245
}
246
elseif(typeofobjid=='object')
247

{
248
returnobjid.value;
249
}
250
},
251
252
/**//*设置指定对象的值,实现可以直接赋值或清除操作
253
@objid对象ID
254
@inserValue传入值(可选项Null:清除该ID的值,则直接赋值)
255
*/
256
SetValue:function(objid,inserValue)
{
257
vargetTagName=this.Get(objid).tagName.toLowerCase();
258
if(inserValue==null)inserValue='';
259
if(getTagName=='input'||getTagName=='textarea')
260

{
261
this.Get(objid).value=inserValue;
262
}
263
elseif(getTagName=='div'||getTagName=='sapn')
264

{
265
266
this.Get(objid).innerText=inserValue;
267
}
268
},
269
270
/**//*拷贝对象值到剪贴板
271
@str对象值
272
*/
273
CopyCode:function(str)
{
274
varrng=document.body.createTextRange();
275
rng.moveToElementText(str);
276
rng.scrollIntoView();
277
rng.select();
278
rng.execCommand("Copy");
279
rng.collapse(false);
280
},
281
282
/**//*显示隐藏一个对象
283
@Objid对象ID
284
@isshow具体操作,指定Obj为False:none或者True:block(可选)
285
*/
286
ShowHidd:function(objid,isshow)
{
287
if(isshow!=null)
288

{
289
if(isshow)
290

{
291
this.Get(objid).style.display='block';
292
}
293
else
294

{
295
this.Get(objid).style.display='none';
296
}
297
}
298
else
299

{
300
if(this.Get(objid).style.display=='none')
301

{
302
this.Get(objid).style.display='block';
303
}
304
else
305

{
306
this.Get(objid).style.display='none';
307
}
308
}
309
},
310
311
/**//*当前对象是否可见
312
@objid对象ID
313
*/
314
IsVisible:function(objid)
{
315
if(this.Get(objid))
316

{
317
try
318

{
319
if(this.Get(objid).style.display=='none')
320

{
321
returnfalse
322
}
323
if(this.Get(objid).style.visibility=='hidden')
324

{
325
returnfalse;
326
}
327
returntrue;
328
}
329
catch(e)
330

{
331
returnfalse;
332
}
333
}
334
else
335

{
336
returnfalse;
337
}
338
}
339
};
340
341
///字符处理
342
varSams_string=
{
343
/**//*取左边的指定长度的值
344
@str要处理的字符集
345
@n长度
346
*/
347
Left:function(str,n)
348

{
349
if(str.length>0)
350

{
351
if(n>str.length)n=str.length;
352
returnstr.substr(0,n)
353
}
354
else
355

{
356
return;
357
}
358
},
359
360
/**//*取右边的指定长度的值
361
@str要处理的字符集
362
@n长度
363
*/
364
Right:function(str,n)
365

{
366
if(str.length>0)
367

{
368
if(n>=str.length)returnstr;
369
returnstr.substr(str.length-n,n);
370
}
371
else
372

{
373
return;
374
}
375
},
376
377
/**//*Trim:清除两边空格
378
@str要处理的字符集
379
*/
380
Trim:function(str)
381

{
382
if(typeofstr=='string')returnstr.replace(/(^/s*)|(/s*$)/g,'');
383
},
384
385
/**//*LTrim:清除左边的空格
386
@str要处理的字符集
387
*/
388
Ltrim:function(str)
389

{
390
if(typeofstr=='string')returnstr.replace(/(^/s*)/g,'');
391
},
392
393
/**//*RTrim:清除右边的空格
394
@str要处理的字符集
395
*/
396
Rtrim:function(str)
397

{
398
if(typeofstr=='string')returnstr.replace(/(/s*$)/g,'');
399
},
400
401
/**//*清除前后的非字符
402
@str要处理的字符集
403
*/
404
strip:function(str)
{
405
if(typeofstr=='string')returnstr.replace(/^/s+/,'').replace(/(^/s*)|(/s*$)/g,'');
406
},
407
408
/**//*过滤字符里面的HTML标签
409
@str要处理的字符集
410
*/
411
stripTags:function(str)
{
412
if(typeofstr=='string')returnstr.replace(/<//?[^>]+>/gi,'').replace(/(^/s*)|(/s*$)/g,'');
413
}
414
};
415
416
///时间相关操作
417
varSams_time=
{
418
/**//*获取当天日期yyyy-MM-dd*/
419
GetDateNow:function()
{
420
vard,y,m,dd;
421
d=newDate();
422
y=d.getYear();
423
m=d.getMonth()+1;
424
dd=d.getDate();
425
returny+"-"+m+"-"+dd;
426
},
427
428
/**//*获取指定日期后的特定天数的日期值
429
@toDate当前指定的日期
430
@N要添加的日期数
431
*/
432
AddDays:function(toDate,N)
{
433
varaDate=this._cvtISOToDate(toDate);
434
if(!aDate)return"";
435
varmillis=86400000*N;
436
aDate=newDate(aDate.getTime()+millis);
437
returnthis._fmtDateISO(aDate);
438
},
439
_fmtDateISO:function(aDate)
{
440
with(aDate)
{
441
varmm=getMonth()+1;
442
if(mm<10)
{mm='0'+mm;}
443
vardd=getDate();
444
if(dd<10)
{dd='0'+dd;}
445
return(getFullYear()+'-'+mm+'-'+dd);
446
}
447
},
448
_cvtISOToDate:function(isoDate)
{
449
varatomDate=isoDate.split('-');
450
varaDate=newDate(parseInt(atomDate[0],10),parseInt(atomDate[1],10)-1,parseInt(atomDate[2],10),6,0,0);
451
returnaDate;
452
}
453
};
454
455
///图像相关操作
456
varSams_media=
{
457
/**//*为单一图像添加鼠标中键放大缩小功能,批量可以直接用ResizeImage(指定添加该功能的图片大小:Int)即可(该功能只适用于IE)
458
objid对象ID
459
*/
460
ZoomFun:function(objid)
{
461
Sams_object.Get(objid).onmousewheel=function()
{returnSams_media.imagecontrol(this);}
462
},
463
464
/**//*重置图片尺寸同时添加放大功能(该功能只适用于IE)
465
@IntSize指定图像的大小
466
如果适合图像大小就添加放大缩小功能
467
*/
468
ResizeImage:function(IntSize)
{
469
varimgsinlog=document.getElementsByTagName('img');
470
for(j=0;j<imgsinlog.length;j++)
{
471
if(imgsinlog[j].width>=IntSize)
{
472
imgsinlog[j].width=IntSize;
473
imgsinlog[j].style.cursor='pointer';
474
imgsinlog[j].onclick=function()
{window.open(this.src);}
475
if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{
476
imgsinlog[j].title='您可以用鼠标中键或者使用Ctrl+鼠标滚轮缩放图片,点击图片可在新窗口打开';
477
imgsinlog[j].onmousewheel=function()
{returnSams_media.imagecontrol(this);};
478
}
479
else
480

{
481
imgsinlog[j].title='点击图片可在新窗口打开';
482
}
483
}
484
}
485
},
486
imagecontrol:function(obj)
{
487
varzoom=parseInt(obj.style.zoom,10)||100;zoom+=event.wheelDelta/12;
488
if(zoom>0)obj.style.zoom=zoom+'%';
489
returnfalse;
490
},
491
492
/**//*如果图像出现下载不了等异常,显示的错误提示图片
493
@errimgpath显示错误提示的图像路径
494
*/
495
ImagesError:function(errimgpath)
{
496
varimglist=document.getElementsByTagName('img');
497
for(j=0;j<imglist.length;j++)
{
498
imglist[j].onerror=function()
{
499
this.src=errimgpath;
500
}
501
}
502
},
503
504
/**//*显示媒体
505
@mFile文件路径
506
@mFileType文件类型(可为空,如为Flash,要指定为swf类型)
507
@ObjID对象ID
508
@mWidth显示的对象宽度
509
@mHeight显示对象的高度
510
注:可以指定对象的ID,如果ID不存在,会自动创建,追加在Body后面
511
*/
512
ShowMedia:function(mFile,mFileType,ObjID,mWidth,mHeight)
{
513
varmediaStr;
514
switch(mFileType)
{
515
case"swf":
516
mediaStr="<objectcodeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'width='"+mWidth+"'height='"+mHeight+"'><paramname='movie'value='"+mFile+"'><paramname='quality'value='high'><paramname='AllowScriptAccess'value='never'><embedsrc='"+mFile+"'quality='high'pluginspage='http://www.macromedia.com/go/getflashplayer'type='application/x-shockwave-flash'width='"+mWidth+"'height='"+mHeight+"'></embed></OBJECT>";
517
break;
518
default:
519
mediaStr="<objectwidth='"+mWidth+"'height='"+mHeight+"'classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'><paramname='url'value='"+mFile+"'/><embedwidth='"+mWidth+"'height='"+mHeight+"'type='application/x-mplayer2'src='"+mFile+"'></embed></object>";
520
}
521
522
varmediaDiv=Sams_object.Get(ObjID);
523
524
if(mediaDiv)
{
525
mediaDiv.innerHTML=mediaStr;
526
}
527
else
528

{
529
mediaDiv=document.createElement("div");
530
mediaDiv.id=ObjID;
531
mediaDiv.innerHTML=mediaStr;
532
document.getElementsByTagName('body')[0].appendChild(mediaDiv);
533
}
534
returnfalse;
535
}
536
};
537
538
///样式相关操作
539
varSams_style=
{
540
/**//*改变字体大小
541
@objid对象ID
542
@size字号
543
*/
544
doZoom:function(objid,size)
{
545
Sams_object.Get(objid).style.fontSize=size+'px';
546
},
547
548
/**//*改变指定对象样式
549
@objid对象ID
550
@className要更改的ClassName
551
*/
552
ClassName:function(objid,className)
{
553
Sams_object.Get(objid).className=className;
554
},
555
556
/**//*对象定位
557
@obj要定位的对象
558
返回X.Y结果的数组对象
559
*/
560
GotoXY:function(obj)
{
561
vart=obj.offsetTop;
562
varl=obj.offsetLeft;
563
while(obj=obj.offsetParent)
{
564
t+=obj.offsetTop;
565
l+=obj.offsetLeft;
566
}
567
returnArray(t,l);
568
}
569
};
570
571
///科学计算
572
varSams_account=
{
573
/**//*逢1进10计算
574
@数值
575
*/
576
GetTen:function(i)
577

{
578
varitems_One,Get_One;
579
if(i.length>1&&(/^/d+$/.test(i)))
580

{
581
items_One=i.substr(0,i.length-1);
582
Get_One=i.substr(i.length-1,1);
583
if(parseInt(Get_One)>0)
584

{
585
items_One=parseInt(items_One)+1;
586
items_One=items_One+'0';
587
}
588
else
589

{
590
items_One=items_One+'0';
591
}
592
}
593
else
594

{
595
items_One=i;
596
}
597
returnitems_One;
598
}
599
};
600
601
///数据验证(所有数值返回值均为Bool型)
602
varSams_validate=
{
603
/**//*是否是数字型数据
604
@str字符集
605
*/
606
IsNumber:function(str)
{
607
if(/^/d+$/.test(str))
{returntrue;}else
{returnfalse;}
608
},
609
610
/**//*是否是数字型数据
611
@objid对象ID
612
*/
613
IsNumberObj:function(objid)
{
614
returnthis.IsNumber(Sams_object.GetValue(objid));
615
},
616
617
/**//*是否是自然数型数据
618
@str字符集
619
*/
620
IsInt:function(str)
{
621
if(/^(/+|-)?/d+$/.test(str))
{returntrue;}else
{returnfalse;}
622
},
623
624
/**//*是否是自然数型数据
625
@objid对象ID
626
*/
627
IsIntObj:function(objid)
{
628
returnthis.IsInt(Sams_object.GetValue(objid));
629
},
630
631
/**//*是否是中文字符
632
@str字符集
633
*/
634
IsChinese:function(str)
635

{
636
if(/^[/u4e00-/u9fa5]+$/.test(str))
{returntrue;}else
{returnfalse;}
637
},
638
639
/**//*是否是中文字符
640
@objid对象ID
641
*/
642
IsChineseObj:function(objid)
643

{
644
returnthis.IsChinese(Sams_object.GetValue(objid));
645
},
646
647
/**//*是否为英文字母
648
@str字符集
649
*/
650
IsLower:function(str)
651

{
652
if(/^[A-Za-z]+$/.test(str))
{returntrue}else
{returnfalse;}
653
},
654
655
/**//*是否为英文字母
656
@objid对象ID
657
*/
658
IsLowerObj:function(objid)
659

{
660
returnthis.IsLower(Sams_object.GetValue(objid));
661
},
662
663
/**//*是否为正确的网址
664
@str字符集
665
*/
666
IsUrl:function(str)
667

{
668
varmyReg=/^((http:[/][/])?/w+([.]/w+|[/]/w*)*)?$/;
669
if(myReg.test(str))
{returntrue;}else
{returnfalse;}
670
},
671
672
/**//*是否为正确的网址
673
@objid对象ID
674
*/
675
IsUrlObj:function(objid)
676

{
677
returnthis.IsUrl(Sams_object.GetValue(objid));
678
},
679
680
/**//*是否为正确的Email形式
681
@str字符集
682
*/
683
IsEmail:function(str)
684

{
685
varmyReg=/^([-_A-Za-z0-9/.]+)@([_A-Za-z0-9]+/.)+[A-Za-z0-9]
{2,3}$/;
686
if(myReg.test(str))
{returntrue;}else
{returnfalse;}
687
},
688
689
690
/**//*是否为正确的Email形式
691
@objid对象ID
692
*/
693
IsEmailObj:function(objid)
694

{
695
returnthis.IsEmail(Sams_object.GetValue(objid));
696
},
697
698
/**//*是否为正确的手机号码
699
@str字符集
700
*/
701
IsMobile:function(str)
702

{
703
varregu=/(^[1][3][0-9]
{9}$)|(^0[1][3][0-9]
{9}$)/;
704
varre=newRegExp(regu);
705
if(re.test(str))
{returntrue;}else
{returnfalse;}
706
},
707
708
/**//*是否为正确的手机号码
709
@objid对象ID
710
*/
711
IsMobileObj:function(objid)
712

{
713
returnthis.IsMobile(Sams_object.GetValue(objid));
714
}
715
};
716
717
/**//*
718
实现Ajax功能
719
Sams_ajax.SendRequest('GET',url,null,recall,"addtohome");
720
Sams_ajax.SendRequest('GET',url,null,null);
721
obj.responseText;
722
*/
723
varSams_ajax=
{
724
_objPool:[],
725
_getInstance:function()
{
726
for(vari=0;i<this._objPool.length;i++)
{
727
if(this._objPool[i].readyState==0||this._objPool[i].readyState==4)
{
728
returnthis._objPool[i];
729
}
730
}
731
this._objPool[this._objPool.length]=this._createObj();
732
returnthis._objPool[this._objPool.length-1];
733
},
734
_createObj:function()
{
735
if(window.XMLHttpRequest)
{
736
varobjXMLHttp=newXMLHttpRequest();
737
}
738
else
{
739
varMSXML=['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];
740
for(varn=0;n<MSXML.length;n++)
{
741
try
{
742
varobjXMLHttp=newActiveXObject(MSXML[n]);
743
break;
744
}
745
catch(e)
{
746
}
747
}
748
}
749
if(objXMLHttp.readyState==null)
{
750
objXMLHttp.readyState=0;
751
objXMLHttp.addEventListener("load",function()
{
752
objXMLHttp.readyState=4;
753
if(typeofobjXMLHttp.onreadystatechange=="function")
{
754
objXMLHttp.onreadystatechange();
755
}
756
},false);
757
}
758
returnobjXMLHttp;
759
},
760
761
///开始发送请求
762
SendRequest:function(method,url,data,callback,funparam,funparam2)
{
763
varobjXMLHttp=this._getInstance();
764
with(objXMLHttp)
{
765
try
{
766
if(url.indexOf("?")>0)
{
767
url+="&randnum="+Math.random();
768
}
769
else
{
770
url+="?randnum="+Math.random();
771
}
772
open(method,url,true);
773
setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');
774
send(data);
775
onreadystatechange=function()
{
776
if(objXMLHttp.readyState==4&&(objXMLHttp.status==200||objXMLHttp.status==304))
777

{
778
callback(objXMLHttp,funparam,funparam2);
779
}else
{
780
callback(null,funparam,funparam2);
781
}
782
}
783
}
784
catch(e)
{
785
alert(e);
786
}
787
}
788
}
789
};
790
791
///Cookies操作
792
varSams_cookies=
{
793
/**//*cookies设置函数
794
@nameCookies名称
795
@value值
796
*/
797
setCookie:function(name,value)
798

{
799
try
800

{
801
varargv=setCookie.arguments;
802
varargc=setCookie.arguments.length;
803
varexpires=(argc>2)?argv[2]:null;
804
if(expires!=null)
805

{
806
varLargeExpDate=newDate();
807
LargeExpDate.setTime(LargeExpDate.getTime()+(expires*1000*3600*24));
808
}
809
document.cookie=name+"="+escape(value)+((expires==null)?"":(";expires="+LargeExpDate.toGMTString()));
810
returntrue;
811
}
812
catch(e)
813

{
814
returnfalse;
815
}
816
},
817
818
/**//*cookies读取函数
819
@NameCookies名称
820
返回值Cookies值
821
*/
822
getCookie:function(Name)
823

{
824
varsearch=Name+"="
825
if(document.cookie.length>0)
826

{
827
offset=document.cookie.indexOf(search)
828
if(offset!=-1)
829

{
830
offset+=search.length
831
end=document.cookie.indexOf(";",offset)
832
if(end==-1)end=document.cookie.length
833
returnunescape(document.cookie.substring(offset,end))
834
}
835
else
836

{
837
return;
838
}
839
}
840
}
841
};
842
1

/**//*------------------------------------------------------------2
*S.SamsLifexperience3
*CopyRight(C)2003-2007S.SamsLifexperienceScriptClassLib4
*MSNLive:S.Sams#msn.com5
*Http://blog.8see.net/6
*UPdateby:2007-01-19转载传播请保留版权7
*-----------------------------------------------------------*/8

9

10

/**//*$获取指定对象11
@element对象名12
可以使用对象名集合,返回值为对象的集合13
如果您使用了Prototype类库,请把该函数注释掉14
Sams_object.Get()中同样实现该函数的所有功能15
*/16

function$(element)
{17

if(arguments.length>1)
{18
for(vari=0,elements=[],length=arguments.length;i<length;i++)19
elements.push($(arguments[i]));20
returnelements;21
}22
if(typeofelement=='string')23
element=document.getElementById(element);24
returnelement;25
}26

27
///浏览器相关操作28

varSams_browse=
{29

/**//*检测浏览信息*/30
checkBrowser:function()31


{32
this.ver=navigator.appVersion33
this.dom=document.getElementById?1:034
this.ie6=(this.ver.indexOf("MSIE6")>-1&&this.dom)?1:0;35
this.ie5=(this.ver.indexOf("MSIE5")>-1&&this.dom)?1:0;36
this.ie4=(document.all&&!this.dom)?1:0;37
this.ns5=(this.dom&&parseInt(this.ver)>=5)?1:0;38
this.ns4=(document.layers&&!this.dom)?1:0;39
this.mac=(this.ver.indexOf('Mac')>-1)?1:0;40
this.ope=(navigator.userAgent.indexOf('Opera')>-1);41
this.ie=(this.ie6||this.ie5||this.ie4)42
this.ns=(this.ns4||this.ns5)43
this.bw=(this.ie6||this.ie5||this.ie4||this.ns5||this.ns4||this.mac||this.ope)44
this.nbw=(!this.bw)45
returnthis;46
},47

48

/**//*设为首页49
@url要设为首页的地址50
*/51
SetDefault:function()52


{53
this.style.behavior='url(#default#homepage)';54
this.setHomePage(this.GetUrl());55
returnfalse;56
},57

58

/**//*复制指定URL地址59
@Msg要写入剪贴板的字符集60
*/61

SetCopy:function(Msg)
{62

if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{63
clipboardData.setData('Text',Msg);64
alert("网址“"+Msg+"”/n已经复制到您的剪贴板中/n您可以使用Ctrl+V快捷键粘贴到需要的地方");65
}66
else67


{68
prompt("请复制网站地址:",Msg);69
}70
},71

72

/**//*加入收藏73
@site站点名称74
@url地址75
*/76

AddBookmark:function(site,url)
{77

if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{78
window.external.addFavorite(url,site)79

}elseif(navigator.userAgent.toLowerCase().indexOf('opera')>-1)
{80
alert("请使用Ctrl+T将本页加入收藏夹");81

}else
{82
alert("请使用Ctrl+D将本页加入收藏夹");83
}84
},85

86

/**//*打开Url指定宽度和高度的窗口*/87
OpenWindows:function(url,width,height)88


{89
window.open(url,'newwin','width='+width+',height='+height);90
returnfalse;91
},92

93

/**//*禁止浏览器的Javascript错误提示*/94

CloseError:function()
{95

window.onerror=function()
{returntrue;};96
},97

98

/**//*获取浏览器URL*/99

GetUrl:function()
{100
returnlocation.href;101
},102

103

/**//*获取URL参数*/104

GetUrlParam:function()
{105
returnlocation.search;106
},107

108

/**//*获取页面来源*/109

GetFrom:function()
{110
returndocument.referrer;111
},112

113

/**//*获取指定的URL参数值114
@name参数名115
*/116

Request:function(name)
{117
varGetUrl=this.GetUrl();118
varPlist=newArray();119
if(GetUrl.indexOf('?')>0)120


{121
Plist=GetUrl.split('?')[1].split('&');122
}123
elseif(GetUrl.indexOf('#')>0)124


{125
Plist=GetUrl.split('#')[1].split('&');126
}127
if(GetUrl.length>0)128


{129
for(vari=0;i<Plist.length;i++)130


{131
varGetValue=Plist[i].split('=');132
if(GetValue[0].toUpperCase()==name.toUpperCase())133


{134
returnGetValue[1];135
break;136
}137
}138
return;139
}140
},141

142

/**//*直接将HTML写到新窗口143
@title标题144
@msg内容145
*/146
Popmsg:functionPopIt(title,msg)147


{148
varpopup=window.open('','popDialog','height=500,width=400,scrollbars=yes');149

popup.document.write('<html><title>'+title+'</title><style>body
{margin:10px;font:13pxArial;}span
{text-line:20px;}</style><body><spanstyle=/'font:14pxarial;/'>'+msg+'</span></body></html>');150
popup.document.close();151
}152
};153

154

155
///对象操作156

varSams_object=
{157

158

/**//*创建一个DIV对象159
@ID要创建的对象ID160
@ClassName创建对象的Class161
@SetValue设置该对象值162
@ToDiv将对象追加到指定的对象,如指定的对象不存在,则追加在Body的后面163
返回创建后的对象164
*/165

CreateDiv:function(ID,ClassName,SetValue,ToDiv)
{166
varcreatediv=document.createElement('div');167
if(ID!=null)creatediv.id=ID;168
creatediv.style.position='absolute';169
if(ClassName!=null)creatediv.className=ClassName;170
if(this.Get(ToDiv))171


{172
this.Get(ToDiv).appendChild(creatediv);173
}174
else175


{176
document.getElementsByTagName('body')[0].appendChild(creatediv);177
}178
this.SetValue(ID,SetValue);179
returnthis.Get(ID);180
},181

182

/**//*删除指定DIV对象183
@objid要删除的对象ID184
返回Bool操作结果185
*/186
DeleteDiv:function(objid)187


{188
try189


{190
if(this.Get(objid))191


{192
varGetParent=this.Get(objid).parentNode;193
GetParent.removeChild(this.Get(objid));194
returntrue;195
}196
else197


{198
returnfalse;199
}200
}201
catch(e)202


{203
returnfalse;204
}205
},206

207

/**//*获取浏览器对象208
@id要获取的对象ID209
可以使用对象名集合,返回值为对象的集合210
*/211

Get:function(objid)
{212

if(arguments.length>1)
{213
for(vari=0,objids=[],length=arguments.length;i<length;i++)214
objids.push(this.Get(arguments[i]));215
returnobjids;216
}217
if(typeofobjid=='string')218


{219

if(document.getElementById)
{220
objid=document.getElementById(objid);221

}elseif(document.all)
{222
objid=document.all[objid];223

}elseif(document.layers)
{224
objid=document.layers[objid];225
}226
}227
returnobjid;228
},229

230

/**//*获取对象的值231
@objid对象ID232
*/233

GetValue:function(objid)
{234
if(typeofobjid=='string')235


{236
vargetTagName=this.Get(objid).tagName.toLowerCase();237
if(getTagName=='input'||getTagName=='textarea'||getTagName=='select')238


{239
returnthis.Get(objid).value;240
}241
elseif(getTagName=='div'||getTagName=='span')242


{243
returnthis.Get(objid).innerText;244
}245
}246
elseif(typeofobjid=='object')247


{248
returnobjid.value;249
}250
},251

252

/**//*设置指定对象的值,实现可以直接赋值或清除操作253
@objid对象ID254
@inserValue传入值(可选项Null:清除该ID的值,则直接赋值)255
*/256

SetValue:function(objid,inserValue)
{257
vargetTagName=this.Get(objid).tagName.toLowerCase();258
if(inserValue==null)inserValue='';259
if(getTagName=='input'||getTagName=='textarea')260


{261
this.Get(objid).value=inserValue;262
}263
elseif(getTagName=='div'||getTagName=='sapn')264


{265

266
this.Get(objid).innerText=inserValue;267
}268
},269

270

/**//*拷贝对象值到剪贴板271
@str对象值272
*/273

CopyCode:function(str)
{274
varrng=document.body.createTextRange();275
rng.moveToElementText(str);276
rng.scrollIntoView();277
rng.select();278
rng.execCommand("Copy");279
rng.collapse(false);280
},281

282

/**//*显示隐藏一个对象283
@Objid对象ID284
@isshow具体操作,指定Obj为False:none或者True:block(可选)285
*/286

ShowHidd:function(objid,isshow)
{287
if(isshow!=null)288


{289
if(isshow)290


{291
this.Get(objid).style.display='block';292
}293
else294


{295
this.Get(objid).style.display='none';296
}297
}298
else299


{300
if(this.Get(objid).style.display=='none')301


{302
this.Get(objid).style.display='block';303
}304
else305


{306
this.Get(objid).style.display='none';307
}308
}309
},310

311

/**//*当前对象是否可见312
@objid对象ID313
*/314

IsVisible:function(objid)
{315
if(this.Get(objid))316


{317
try318


{319
if(this.Get(objid).style.display=='none')320


{321
returnfalse322
}323
if(this.Get(objid).style.visibility=='hidden')324


{325
returnfalse;326
}327
returntrue;328
}329
catch(e)330


{331
returnfalse;332
}333
}334
else335


{336
returnfalse;337
}338
}339
};340

341
///字符处理342

varSams_string=
{343

/**//*取左边的指定长度的值344
@str要处理的字符集345
@n长度346
*/347
Left:function(str,n)348


{349
if(str.length>0)350


{351
if(n>str.length)n=str.length;352
returnstr.substr(0,n)353
}354
else355


{356
return;357
}358
},359

360

/**//*取右边的指定长度的值361
@str要处理的字符集362
@n长度363
*/364
Right:function(str,n)365


{366
if(str.length>0)367


{368
if(n>=str.length)returnstr;369
returnstr.substr(str.length-n,n);370
}371
else372


{373
return;374
}375
},376

377

/**//*Trim:清除两边空格378
@str要处理的字符集379
*/380
Trim:function(str)381


{382
if(typeofstr=='string')returnstr.replace(/(^/s*)|(/s*$)/g,'');383
},384

385

/**//*LTrim:清除左边的空格386
@str要处理的字符集387
*/388
Ltrim:function(str)389


{390
if(typeofstr=='string')returnstr.replace(/(^/s*)/g,'');391
},392

393

/**//*RTrim:清除右边的空格394
@str要处理的字符集395
*/396
Rtrim:function(str)397


{398
if(typeofstr=='string')returnstr.replace(/(/s*$)/g,'');399
},400

401

/**//*清除前后的非字符402
@str要处理的字符集403
*/404

strip:function(str)
{405
if(typeofstr=='string')returnstr.replace(/^/s+/,'').replace(/(^/s*)|(/s*$)/g,'');406
},407

408

/**//*过滤字符里面的HTML标签409
@str要处理的字符集410
*/411

stripTags:function(str)
{412
if(typeofstr=='string')returnstr.replace(/<//?[^>]+>/gi,'').replace(/(^/s*)|(/s*$)/g,'');413
}414
};415

416
///时间相关操作417

varSams_time=
{418

/**//*获取当天日期yyyy-MM-dd*/419

GetDateNow:function()
{420
vard,y,m,dd;421
d=newDate();422
y=d.getYear();423
m=d.getMonth()+1;424
dd=d.getDate();425
returny+"-"+m+"-"+dd;426
},427

428

/**//*获取指定日期后的特定天数的日期值429
@toDate当前指定的日期430
@N要添加的日期数431
*/432

AddDays:function(toDate,N)
{433
varaDate=this._cvtISOToDate(toDate);434
if(!aDate)return"";435
varmillis=86400000*N;436
aDate=newDate(aDate.getTime()+millis);437
returnthis._fmtDateISO(aDate);438
},439

_fmtDateISO:function(aDate)
{440

with(aDate)
{441
varmm=getMonth()+1;442

if(mm<10)
{mm='0'+mm;}443
vardd=getDate();444

if(dd<10)
{dd='0'+dd;}445
return(getFullYear()+'-'+mm+'-'+dd);446
}447
},448

_cvtISOToDate:function(isoDate)
{449
varatomDate=isoDate.split('-');450
varaDate=newDate(parseInt(atomDate[0],10),parseInt(atomDate[1],10)-1,parseInt(atomDate[2],10),6,0,0);451
returnaDate;452
}453
};454

455
///图像相关操作456

varSams_media=
{457

/**//*为单一图像添加鼠标中键放大缩小功能,批量可以直接用ResizeImage(指定添加该功能的图片大小:Int)即可(该功能只适用于IE)458
objid对象ID459
*/460

ZoomFun:function(objid)
{461

Sams_object.Get(objid).onmousewheel=function()
{returnSams_media.imagecontrol(this);}462
},463

464

/**//*重置图片尺寸同时添加放大功能(该功能只适用于IE)465
@IntSize指定图像的大小466
如果适合图像大小就添加放大缩小功能467
*/468

ResizeImage:function(IntSize)
{469
varimgsinlog=document.getElementsByTagName('img');470

for(j=0;j<imgsinlog.length;j++)
{471

if(imgsinlog[j].width>=IntSize)
{472
imgsinlog[j].width=IntSize;473
imgsinlog[j].style.cursor='pointer';474

imgsinlog[j].onclick=function()
{window.open(this.src);}475

if(navigator.userAgent.toLowerCase().indexOf('ie')>-1)
{476
imgsinlog[j].title='您可以用鼠标中键或者使用Ctrl+鼠标滚轮缩放图片,点击图片可在新窗口打开';477

imgsinlog[j].onmousewheel=function()
{returnSams_media.imagecontrol(this);};478
}479
else480


{481
imgsinlog[j].title='点击图片可在新窗口打开';482
}483
}484
}485
},486

imagecontrol:function(obj)
{487
varzoom=parseInt(obj.style.zoom,10)||100;zoom+=event.wheelDelta/12;488
if(zoom>0)obj.style.zoom=zoom+'%';489
returnfalse;490
},491

492

/**//*如果图像出现下载不了等异常,显示的错误提示图片493
@errimgpath显示错误提示的图像路径494
*/495

ImagesError:function(errimgpath)
{496
varimglist=document.getElementsByTagName('img');497

for(j=0;j<imglist.length;j++)
{498

imglist[j].onerror=function()
{499
this.src=errimgpath;500
}501
}502
},503

504

/**//*显示媒体505
@mFile文件路径506
@mFileType文件类型(可为空,如为Flash,要指定为swf类型)507
@ObjID对象ID508
@mWidth显示的对象宽度509
@mHeight显示对象的高度510
注:可以指定对象的ID,如果ID不存在,会自动创建,追加在Body后面511
*/512

ShowMedia:function(mFile,mFileType,ObjID,mWidth,mHeight)
{513
varmediaStr;514

switch(mFileType)
{515
case"swf":516
mediaStr="<objectcodeBase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0'classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'width='"+mWidth+"'height='"+mHeight+"'><paramname='movie'value='"+mFile+"'><paramname='quality'value='high'><paramname='AllowScriptAccess'value='never'><embedsrc='"+mFile+"'quality='high'pluginspage='http://www.macromedia.com/go/getflashplayer'type='application/x-shockwave-flash'width='"+mWidth+"'height='"+mHeight+"'></embed></OBJECT>";517
break;518
default:519
mediaStr="<objectwidth='"+mWidth+"'height='"+mHeight+"'classid='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6'><paramname='url'value='"+mFile+"'/><embedwidth='"+mWidth+"'height='"+mHeight+"'type='application/x-mplayer2'src='"+mFile+"'></embed></object>";520
}521

522
varmediaDiv=Sams_object.Get(ObjID);523

524

if(mediaDiv)
{525
mediaDiv.innerHTML=mediaStr;526
}527
else528


{529
mediaDiv=document.createElement("div");530
mediaDiv.id=ObjID;531
mediaDiv.innerHTML=mediaStr;532
document.getElementsByTagName('body')[0].appendChild(mediaDiv);533
}534
returnfalse;535
}536
};537

538
///样式相关操作539

varSams_style=
{540

/**//*改变字体大小541
@objid对象ID542
@size字号543
*/544

doZoom:function(objid,size)
{545
Sams_object.Get(objid).style.fontSize=size+'px';546
},547

548

/**//*改变指定对象样式549
@objid对象ID550
@className要更改的ClassName551
*/552

ClassName:function(objid,className)
{553
Sams_object.Get(objid).className=className;554
},555

556

/**//*对象定位557
@obj要定位的对象558
返回X.Y结果的数组对象559
*/560

GotoXY:function(obj)
{561
vart=obj.offsetTop;562
varl=obj.offsetLeft;563

while(obj=obj.offsetParent)
{564
t+=obj.offsetTop;565
l+=obj.offsetLeft;566
}567
returnArray(t,l);568
}569
};570

571
///科学计算572

varSams_account=
{573

/**//*逢1进10计算574
@数值575
*/576
GetTen:function(i)577


{578
varitems_One,Get_One;579
if(i.length>1&&(/^/d+$/.test(i)))580


{581
items_One=i.substr(0,i.length-1);582
Get_One=i.substr(i.length-1,1);583
if(parseInt(Get_One)>0)584


{585
items_One=parseInt(items_One)+1;586
items_One=items_One+'0';587
}588
else589


{590
items_One=items_One+'0';591
}592
}593
else594


{595
items_One=i;596
}597
returnitems_One;598
}599
};600

601
///数据验证(所有数值返回值均为Bool型)602

varSams_validate=
{603

/**//*是否是数字型数据604
@str字符集605
*/606

IsNumber:function(str)
{607

if(/^/d+$/.test(str))
{returntrue;}else
{returnfalse;}608
},609

610

/**//*是否是数字型数据611
@objid对象ID612
*/613

IsNumberObj:function(objid)
{614
returnthis.IsNumber(Sams_object.GetValue(objid));615
},616

617

/**//*是否是自然数型数据618
@str字符集619
*/620

IsInt:function(str)
{621

if(/^(/+|-)?/d+$/.test(str))
{returntrue;}else
{returnfalse;}622
},623

624

/**//*是否是自然数型数据625
@objid对象ID626
*/627

IsIntObj:function(objid)
{628
returnthis.IsInt(Sams_object.GetValue(objid));629
},630

631

/**//*是否是中文字符632
@str字符集633
*/634
IsChinese:function(str)635


{636

if(/^[/u4e00-/u9fa5]+$/.test(str))
{returntrue;}else
{returnfalse;}637
},638

639

/**//*是否是中文字符640
@objid对象ID641
*/642
IsChineseObj:function(objid)643


{644
returnthis.IsChinese(Sams_object.GetValue(objid));645
},646

647

/**//*是否为英文字母648
@str字符集649
*/650
IsLower:function(str)651


{652

if(/^[A-Za-z]+$/.test(str))
{returntrue}else
{returnfalse;}653
},654

655

/**//*是否为英文字母656
@objid对象ID657
*/658
IsLowerObj:function(objid)659


{660
returnthis.IsLower(Sams_object.GetValue(objid));661
},662

663

/**//*是否为正确的网址664
@str字符集665
*/666
IsUrl:function(str)667


{668
varmyReg=/^((http:[/][/])?/w+([.]/w+|[/]/w*)*)?$/;669

if(myReg.test(str))
{returntrue;}else
{returnfalse;}670
},671

672

/**//*是否为正确的网址673
@objid对象ID674
*/675
IsUrlObj:function(objid)676


{677
returnthis.IsUrl(Sams_object.GetValue(objid));678
},679

680

/**//*是否为正确的Email形式681
@str字符集682
*/683
IsEmail:function(str)684


{685

varmyReg=/^([-_A-Za-z0-9/.]+)@([_A-Za-z0-9]+/.)+[A-Za-z0-9]
{2,3}$/;686

if(myReg.test(str))
{returntrue;}else
{returnfalse;}687
},688

689

690

/**//*是否为正确的Email形式691
@objid对象ID692
*/693
IsEmailObj:function(objid)694


{695
returnthis.IsEmail(Sams_object.GetValue(objid));696
},697

698

/**//*是否为正确的手机号码699
@str字符集700
*/701
IsMobile:function(str)702


{703

varregu=/(^[1][3][0-9]
{9}$)|(^0[1][3][0-9]
{9}$)/;704
varre=newRegExp(regu);705

if(re.test(str))
{returntrue;}else
{returnfalse;}706
},707

708

/**//*是否为正确的手机号码709
@objid对象ID710
*/711
IsMobileObj:function(objid)712


{713
returnthis.IsMobile(Sams_object.GetValue(objid));714
}715
};716

717

/**//*718
实现Ajax功能719
Sams_ajax.SendRequest('GET',url,null,recall,"addtohome");720
Sams_ajax.SendRequest('GET',url,null,null);721
obj.responseText;722
*/723

varSams_ajax=
{724
_objPool:[],725

_getInstance:function()
{726

for(vari=0;i<this._objPool.length;i++)
{727

if(this._objPool[i].readyState==0||this._objPool[i].readyState==4)
{728
returnthis._objPool[i];729
}730
}731
this._objPool[this._objPool.length]=this._createObj();732
returnthis._objPool[this._objPool.length-1];733
},734

_createObj:function()
{735

if(window.XMLHttpRequest)
{736
varobjXMLHttp=newXMLHttpRequest();737
}738

else
{739
varMSXML=['MSXML2.XMLHTTP.5.0','MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'];740

for(varn=0;n<MSXML.length;n++)
{741

try
{742
varobjXMLHttp=newActiveXObject(MSXML[n]);743
break;744
}745

catch(e)
{746
}747
}748
}749

if(objXMLHttp.readyState==null)
{750
objXMLHttp.readyState=0;751

objXMLHttp.addEventListener("load",function()
{752
objXMLHttp.readyState=4;753

if(typeofobjXMLHttp.onreadystatechange=="function")
{754
objXMLHttp.onreadystatechange();755
}756
},false);757
}758
returnobjXMLHttp;759
},760

761
///开始发送请求762

SendRequest:function(method,url,data,callback,funparam,funparam2)
{763
varobjXMLHttp=this._getInstance();764

with(objXMLHttp)
{765

try
{766

if(url.indexOf("?")>0)
{767
url+="&randnum="+Math.random();768
}769

else
{770
url+="?randnum="+Math.random();771
}772
open(method,url,true);773
setRequestHeader('Content-Type','application/x-www-form-urlencoded;charset=UTF-8');774
send(data);775

onreadystatechange=function()
{776
if(objXMLHttp.readyState==4&&(objXMLHttp.status==200||objXMLHttp.status==304))777


{778
callback(objXMLHttp,funparam,funparam2);779

}else
{780
callback(null,funparam,funparam2);781
}782
}783
}784

catch(e)
{785
alert(e);786
}787
}788
}789
};790

791
///Cookies操作792

varSams_cookies=
{793

/**//*cookies设置函数794
@nameCookies名称795
@value值796
*/797
setCookie:function(name,value)798


{799
try800


{801
varargv=setCookie.arguments;802
varargc=setCookie.arguments.length;803
varexpires=(argc>2)?argv[2]:null;804
if(expires!=null)805


{806
varLargeExpDate=newDate();807
LargeExpDate.setTime(LargeExpDate.getTime()+(expires*1000*3600*24));808
}809
document.cookie=name+"="+escape(value)+((expires==null)?"":(";expires="+LargeExpDate.toGMTString()));810
returntrue;811
}812
catch(e)813


{814
returnfalse;815
}816
},817

818

/**//*cookies读取函数819
@NameCookies名称820
返回值Cookies值821
*/822
getCookie:function(Name)823


{824
varsearch=Name+"="825
if(document.cookie.length>0)826


{827
offset=document.cookie.indexOf(search)828
if(offset!=-1)829


{830
offset+=search.length831
end=document.cookie.indexOf(";",offset)832
if(end==-1)end=document.cookie.length833
returnunescape(document.cookie.substring(offset,end))834
}835
else836


{837
return;838
}839
}840
}841
};842

被折叠的 条评论
为什么被折叠?



