// 等比缩放图片: function rs(el){ //首先判断图片是长的还是宽的。如果是长的就对宽进行变形,否则对高进行变形 (el.width>el.height+10)?el.width = math.min(120,el.width):el.height = math.min(110,el.height); } //div等高:放在后resetdiv("id","id","id") function resetdiv(){ if(arguments.length > 1){ var x = arguments.length; var elements=[]; for(i=0;i elements[1]){ document.getelementbyid(arguments[1]).style.height = imax+"px"; } else { document.getelementbyid(arguments[0]).style.height = elements[1]+"px"; } } } //显示时间 function time(){ } function timeshow(){ var date = new date(); //日期对象 if(date.getday()==0)day="星期天"//sunday if(date.getday()==1)day="星期一"//monday if(date.getday()==2)day="星期二"//tuesday if(date.getday()==3)day="星期三"//wednesday if(date.getday()==4)day="星期四"//thursday if(date.getday()==5)day="星期五"//friday if(date.getday()==6)day="星期六"//saturday var now = "今天是:"; now = now + date.getfullyear()+"年"; //读英文就行了 now = now + (date.getmonth()+1)+"月"; //取月的时候取的是当前月-1如果想取当前月+1就可以了 now = now + date.getdate()+"日"; now = now + " "; now = now + day; // now = now + date.gethours()+"时"; // now = now + date.getminutes()+"分"; // now = now + date.getseconds()+"秒"; document.getelementbyid("nowdiv").innerhtml = now; //div的html是now这个字符串 settimeout("timeshow()",1000); //设置过1000毫秒就是1秒,调用show方法 window.onload = timeshow; } function time_en(){ } //滚动 function divscroll(tabid,tab1id,tab2id,direction){ var speed=25; //数字越大速度越慢 var _stop = 0; var tab= document.getelementbyid(tabid); var tab1 = document.getelementbyid(tab1id); var tab2 = document.getelementbyid(tab2id); tab2.innerhtml=tab1.innerhtml; switch (direction) { case "up" : var mymar=setinterval(marqueeup,speed); //定时滚动 tab.onmouseover=function() {clearinterval(mymar)}; tab.onmouseout=function() {mymar=setinterval(marqueeup,speed)}; break; default: var mymar=setinterval(marqueeleft,speed); //定时滚动 tab.onmouseover=function() {clearinterval(mymar)}; tab.onmouseout=function() {mymar=setinterval(marqueeleft,speed)}; break; break; } /*向左滚动*/ function marqueeleft(){ if(tab1.offsetwidth-tab.scrollleft<=0) tab.scrollleft-=tab1.offsetwidth; else{ tab.scrollleft++; } } /*向上滚动*/ function marqueeup(){ if(tab2.offsettop-tab.scrolltop<=0) tab.scrolltop-=tab1.offsetheight; else{ tab.scrolltop++; } } } //切换选项卡 function changetab(group,num,sel) { for(var i=0;i document.body.clientwidth + document.body.scrollleft - 1) { curleft = document.body.scrollleft + document.body.clientwidth - ad.offsetwidth; ad.dirh = false; } if(ad.offsetheight + curtop > document.body.clientheight + document.body.scrolltop - 1) { curtop = document.body.scrolltop + document.body.clientheight - ad.offsetheight; ad.dirv = false; } if(curleft < document.body.scrollleft) { curleft = document.body.scrollleft; ad.dirh = true; } if(curtop < document.body.scrolltop) { curtop = document.body.scrolltop; ad.dirv = true; } ad.style.left = curleft + (ad.dirh ? 1 : -1) + "px"; ad.style.top = curtop + (ad.dirv ? 1 : -1) + "px"; } } } //加入收藏 - 使用方法:加入收藏 function addfavorite(surl, stitle) { try { window.external.addfavorite(surl, stitle); } catch (e) { try { window.sidebar.addpanel(stitle, surl, ""); } catch (e) { alert("加入收藏失败,请使用ctrl+d进行添加"); } } } //设为首页 - 使用方法:设为首页 function sethome(obj,vrl){ try{ obj.style.behavior='url(#default#homepage)';obj.sethomepage(vrl); } catch(e){ if(window.netscape) { try { netscape.security.privilegemanager.enableprivilege("universalxpconnect"); } catch (e) { alert("此操作被浏览器拒绝!请在浏览器地址栏输入\"about:config\"并回车然后将[signed.applets.codebase_principal_support]设置为'true'"); [page] } var prefs = components.classes['@mozilla.org/preferences-service;1'].getservice(components.interfaces.nsiprefbranch); prefs.setcharpref('browser.startup.homepage',vrl); } } }