日期:2014-05-17  浏览次数:20652 次

CSS+DIV下拉菜单
这是JS文件
//Chrome   Drop   Down   Menu-   Author:   Dynamic   Drive   (http://www.dynamicdrive.com)
//Last   updated:   June   14th,   06 '

var   cssdropdown={
disappeardelay:   250,   //set   delay   in   miliseconds   before   menu   disappears   onmouseout
disablemenuclick:   true,   //when   user   clicks   on   a   menu   item   with   a   drop   down   menu,   disable   menu   item 's   link?
enableswipe:   1,   //enable   swipe   effect?   1   for   yes,   0   for   no

//No   need   to   edit   beyond   here////////////////////////
dropmenuobj:   null,   ie:   document.all,   firefox:   document.getElementById&&!document.all,   swipetimer:   undefined,   bottomclip:0,

getposOffset:function(what,   offsettype){
var   totaloffset=(offsettype== "left ")?   what.offsetLeft   :   what.offsetTop;
var   parentEl=what.offsetParent;
while   (parentEl!=null){
totaloffset=(offsettype== "left ")?   totaloffset+parentEl.offsetLeft   :   totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return   totaloffset;
},

swipeeffect:function(){
if   (this.bottomclip <parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10)   //unclip   drop   down   menu   visibility   gradually
this.dropmenuobj.style.clip= "rect(0   auto   "+this.bottomclip+ "px   0) "
}
else
return
this.swipetimer=setTimeout( "cssdropdown.swipeeffect() ",   10)
},

showhide:function(obj,   e){
if   (this.ie   ||   this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top= "-500px "
if   (e.type== "click "   &&   obj.visibility==hidden   ||   e.type== "mouseover "){
if   (this.enableswipe==1){
if   (typeof   this.swipetimer!= "undefined ")
clearTimeout(this.swipetimer)
obj.clip= "rect(0   auto   0   0) "   //hide   menu   via   clipping
this.bottomclip=0
this.swipeeffect()
}
obj.visibility= "visible "
}
else   if   (e.type== "click ")
obj.visibility= "hidden "
},

iecompattest:function(){
return   (document.compatMode   &&   document.compatMode!= "BackCompat ")?   document.documentElement   :   document.body
},

clearbrowseredge:function(obj,   whichedge){
var   edgeoffset=0
if   (whichedge== "rightedge "){
var   windowedge=this.ie   &&   !window.opera?   this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15   :   window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if   (windowedge-this.dropmenuobj.x   <   this.dropmenuobj.contentmeasure)     //move   menu   to   the   left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var   topedge=this.ie   &&   !window.opera?   this.iecompattest().scrollTop   :   window.pageYOffset
var   win