// javascript document ///二级菜单//// $(function(){ //subnav $(".nav li").hover(function(){ //$("dl",this).css("display","block"); $("dl",this).fadein("fast"); $(this).addclass("hover"); },function(){ //$("dl",this).css("display","none"); $("dl",this).hide("fast"); $(this).removeclass("hover"); }); // //中间提示框 //$("#cbtn").click(function(){ //$("#cpop").center(); //}); $("#oalogin").hover(function(){ $("#oa").show(); },function(){ $("#oa").hide(); }); $("#oa").hover(function(){ $("#oa").show(); //$("#oalogin").hide(); $("#oalogin").addclass("hover"); },function(){ $("#oa").hide(); $("#oalogin").removeclass("hover"); }); }) function checksearch(the) { if(the.key.value=="") { alert("请输入关键字"); the.key.focus(); return false } } //////gotop/////// $(function(){ $(window).scroll(function(){ //只要窗口滚动,就触发下面代码 var scrollt = document.documentelement.scrolltop + document.body.scrolltop; //获取滚动后的高度 if( scrollt >200 ){ //判断滚动后高度超过200px,就显示 $("#gotop").fadein(400); //淡出 }else{ $("#gotop").stop().fadeout(400); //如果返回或者没有超过,就淡入.必须加上stop()停止之前动画,否则会出现闪动 } }); $("#gotop").click(function(){ //当点击标签的时候,使用animate在200毫秒的时间内,滚到顶部 $("html,body").animate({scrolltop:"0px"},200); }); }); ////picmove_left//// var speed=30//速度数值越大速度越慢 var colee_left2=document.getelementbyid("colee_left2"); var colee_left1=document.getelementbyid("colee_left1"); var colee_left=document.getelementbyid("colee_left"); colee_left2.innerhtml=colee_left1.innerhtml function marquee3(){ if(colee_left2.offsetwidth-colee_left.scrollleft<=0)//offsetwidth 是对象的可见宽度 colee_left.scrollleft-=colee_left1.offsetwidth//scrollwidth 是对象的实际内容的宽,不包边线宽度 else{ colee_left.scrollleft++ } } var mymar3=setinterval(marquee3,speed) colee_left.onmouseover=function() {clearinterval(mymar3)} colee_left.onmouseout=function() {mymar3=setinterval(marquee3,speed)} //center pop///// //这个函数主要的功能计算页面的大小,屏幕的大小,返回值为array,不必要细读,返回值为一个array function ___getpagesize() { var xscroll, yscroll; if (window.innerheight && window.scrollmaxy) { xscroll = window.innerwidth + window.scrollmaxx; yscroll = window.innerheight + window.scrollmaxy; } else if (document.body.scrollheight > document.body.offsetheight){ // all but explorer mac xscroll = document.body.scrollwidth; yscroll = document.body.scrollheight; } else { // explorer mac...would also work in explorer 6 strict, mozilla and safari xscroll = document.body.offsetwidth; yscroll = document.body.offsetheight; } var windowwidth, windowheight; if (self.innerheight) { // all except explorer if(document.documentelement.clientwidth){ windowwidth = document.documentelement.clientwidth; } else { windowwidth = self.innerwidth; } windowheight = self.innerheight; } else if (document.documentelement && document.documentelement.clientheight) { // explorer 6 strict mode windowwidth = document.documentelement.clientwidth; windowheight = document.documentelement.clientheight; } else if (document.body) { // other explorers windowwidth = document.body.clientwidth; windowheight = document.body.clientheight; } // for small pages with total height less then height of the viewport if(yscroll < windowheight){ pageheight = windowheight; } else { pageheight = yscroll; } // for small pages with total width less then width of the viewport if(xscroll < windowwidth){ pagewidth = xscroll; } else { pagewidth = windowwidth; } arraypagesize = new array(pagewidth,pageheight,windowwidth,windowheight); return arraypagesize; }; function showproc(){ var message_box = document.getelementbyid("message_box"); var cpop = document.getelementbyid("cpop"); message_box.style.visibility='visible'; cpop.style.display='block'; // message_box.style.left = var pagesize = ___getpagesize();//这里的方法 返回的是页面的宽度,页面的高度,屏幕的高度,屏幕的宽度! var pagewidth = pagesize[0];//页面的宽度 var pageheight = 506;//页面的高度 var screenwidth = pagesize[2];//屏幕的宽度 var screenheight = pagesize[3];//屏幕的高度 var divwidth = 500;//div的宽度 var divheight = 352;//div 的高度 message_box.style.width = divwidth+"px";//设置div 的宽度 message_box.style.height = divheight+"px";//设置div的高度 message_box.style.left = (screenwidth-divwidth)/2+"px";//弹出div层屏幕中水平居中的位置 message_box.style.top = (screenheight-divheight)/2+"px";//弹出div层屏幕垂直居中的位置 //message_box.style.top = (screenheight-pageheight+divheight)/2+"px";//弹出div层,所属上一层div居中的位置,本实例中就为contentdiv高度一半的位置 //alert(pagesize) 打印的数据可以看出screenheight 和pageheight的高度是一样的,可能__getpagesize计算屏幕或者页面的高度有问题!所以关于div垂直居中的问题,请大家手动解决 //创建灰色背景层 procbg = document.createelement("div"); procbg.setattribute("id","mybg"); procbg.style.background = "#fff"; procbg.style.width = "100%"; procbg.style.height = "110%"; procbg.style.position = "absolute"; procbg.style.top = "0"; procbg.style.left = "0"; procbg.style.zindex = "500"; procbg.style.opacity = "0.5"; procbg.style.filter = "alpha(opacity=50)"; //背景层加入页面 document.body.appendchild(procbg); document.body.style.overflow = "hidden"; } //拖动 $().ready(function() { $('#message_box').drags({ handler: '#dragdiv', zindex:200, opacity:.9 }); }); function closeproc(){ var message_box = document.getelementbyid("message_box"); message_box.style.visibility='hidden'; procbg.style.visibility = "hidden"; cpop.style.display='none'; document.body.style.overflow = "auto"; }