非常不错的一个javascript 类
2024-09-06 12:44:35
供稿:网友
非常不错的一个javascript 类
代码如下:
/*
* Author:aoao
* Homepage:http://www.loaoao.com
* Email:loaoao@gmail.com / QQ:2222342
* Copyright (c) 2006 aoao
* Licensed under a Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/)
*/
var jscc = new Object();
var loaoao = new Object();//^_^//
jscc = {
init:function(){/*_*/},
path:"/scripts/jscc/",
include:function (file){
var j=document.createElement("script");
j.setAttribute('type','text/javascript');
j.setAttribute('src',jscc.path+file+'.js');
document.getElementsByTagName("head")[0].appendChild(j);
}
};
jscc.addEvent = function( obj, type, fn ) {
if ( obj.attachEvent ) {
obj['e'+type+fn] = fn;
obj[type+fn] = function(){obj['e'+type+fn]( window.event );}
obj.attachEvent( 'on'+type, obj[type+fn] );
} else {
obj.addEventListener( type, fn, false );
}
};
// Cookies
jscc.cookie = {
create:function (name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else expires = "";
document.cookie = name+"="+value+expires+"; path=/";
},
read:function(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];