// javascript document var adsdls = new scrollpicleft(); adsdls.scrollcontid = "scrolls"; // 内容容器id"" adsdls.arrleftid = "leftiddls"; //左箭头id adsdls.arrrightid = "rightiddls"; //右箭头id adsdls.framewidth = 1200; //显示框宽度 adsdls.pagewidth = 405; //翻页宽度 adsdls.speed = 10; //移动速度(单位毫秒,越小越快) adsdls.space = 10; //每次移动像素(单位px,越大越快) adsdls.autoplay = true; //自动播放 adsdls.autoplaytime = 2; //自动播放间隔时间(秒) adsdls.initialize(); //初始化 var adsdls1 = new scrollpicleft(); adsdls1.scrollcontid = "scrolls1"; // 内容容器id"" adsdls1.arrleftid = "leftiddls1"; //左箭头id adsdls1.arrrightid = "rightiddls1"; //右箭头id adsdls1.framewidth = 1200; //显示框宽度 adsdls1.pagewidth = 405; //翻页宽度 adsdls1.speed = 10; //移动速度(单位毫秒,越小越快) adsdls1.space = 10; //每次移动像素(单位px,越大越快) adsdls1.autoplay = true; //自动播放 adsdls1.autoplaytime = 2; //自动播放间隔时间(秒) adsdls1.initialize(); //初始化 var bianyuan = { //添加事件2(dom-保证this指向对象是obj) 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); } }, //获取id元素 $ : function(id){ return document.getelementbyid(id); }, //取得浏览器可视区size getbrowsersize : function(){ var pagewidth = window.innerwidth, pageheight = window.innerheight; if (typeof pagewidth != "number"){ if (document.compatmode == "css1compat"){ pagewidth = document.documentelement.clientwidth; pageheight = document.documentelement.clientheight; } else{ pagewidth = document.body.clientwidth; pagewidth = document.body.clientheight; } } //ie减去17滚动条宽度 if(!window.activexobject){ pagewidth -= 17; } return { width : pagewidth, height : pageheight } }, //获取滚动条高度 getpagescroll : function(){ var yscroll; if (self.pageyoffset) { yscroll = self.pageyoffset; } else if (document.documentelement && document.documentelement.scrolltop){ yscroll = document.documentelement.scrolltop; } else if (document.body) { yscroll = document.body.scrolltop; } return yscroll; } } function scrollbar(scrollid, dir, headheight, footheight, areawidth, o){ //滚动框宽高 var scrollbar = bianyuan.$(scrollid), barwidth = scrollbar.offsetwidth, barheight = scrollbar.offsetheight; //可视区宽高 var pagewidth = bianyuan.getbrowsersize().width, pageheight = bianyuan.getbrowsersize().height; //内容宽高 var widthmore = document.documentelement.scrollwidth, heightmore = document.body.scrollheight||(document.documentelement.scrollheight); //最大宽高 var maxwidth = math.max(pagewidth, widthmore), maxheight = math.max(pageheight, heightmore); scrollbar.style.position = 'absolute'; //设置top--假设滚动框高度小于整个页面高度,如果大于直接将其隐藏 if (maxheight < (barheight + footheight + footheight + 4)){ scrollbar.style.display = 'none'; }else{ //不挡顶部---如果想改距顶高度,改下边的第一个2值 scrollbar.style.top = bianyuan.getpagescroll() + headheight + 2 + 'px'; //不挡底部 if ((heightmore - bianyuan.getpagescroll() - barheight) <= footheight){ scrollbar.style.top = heightmore - footheight - barheight - 2 + 'px'; } } //无视主体内容-左右 if (dir == 'left' && areawidth == 1){ scrollbar.style.left = 2 + 'px'; }else if (dir == 'right' && areawidth == 1){ scrollbar.style.left = maxwidth - barwidth - 2 + 'px'; //根据主体内容宽-左右 }else if (dir == 'left' && areawidth != 1){ if (pagewidth >= (barwidth*2 + areawidth + 4)){ scrollbar.style.left = (pagewidth - areawidth)/2 - barwidth - 2 + 'px'; }else{ scrollbar.style.left = 2 + 'px'; } }else if (dir == 'right' && areawidth != 1){ if (pagewidth >= (barwidth*2 + areawidth + 4)){ scrollbar.style.left = (pagewidth - areawidth)/2 + areawidth + 2 + 'px'; }else{ scrollbar.style.left = maxwidth - barwidth - 2 + 'px'; } } //改变窗口大小或滚动条滚动 resizewindow(scrollid, dir, headheight, footheight, areawidth, o); } function resizewindow(scrollid, dir, headheight, footheight, areawidth, o){ window.onresize = function(){scrollbar(scrollid, dir, headheight, footheight, areawidth, o);} window.onscroll = function(){scrollbar(scrollid, dir, headheight, footheight, areawidth, o);} } function settabta(nameid){ document.getelementbyid("name-"+nameid).style.display='block' } function settabta2(nameid){ document.getelementbyid("name-"+nameid).style.display='none' } function settab(name,cursel,n){ for(i=1;i<=n;i++){ var menu=document.getelementbyid(name+i); var con=document.getelementbyid("con_"+name+"_"+i); menu.classname=i==cursel?"hover":""; con.style.display=i==cursel?"block":"none"; } } function click_a(divdisplay) { if(document.getelementbyid(divdisplay).style.display != "none") { document.getelementbyid(divdisplay).style.display = "none"; } else { document.getelementbyid(divdisplay).style.display = "block"; } }