⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch11-142.txt

📁 javascript demo thanks please
💻 TXT
📖 第 1 页 / 共 2 页
字号:
<HTML>
<HEAD>
<TITLE>菜单导航篇--顶部菜单</TITLE>
</HEAD>

<BODY bgcolor="#fef4d2" >

<br><br>
<center>
<font color="ffaafa"><h2>菜单导航篇--顶部菜单</h2></font>
<hr width=300>
<br><br>

<!-- 案例代码开始 -->

<script language=JavaScript>

var JDWMinIE4   = (document.all) ? 1 : 0;
var JDWMinIE5   = (JDWMinIE4 && navigator.appVersion.indexOf("5.")  >= 0) ? 1 : 0;

function hideLayer(layer) {
if (JDWMinIE4) layer.style.visibility = "hidden";
}

function showLayer(layer) {
if (JDWMinIE4) layer.style.visibility = "visible";
}

function inheritLayer(layer) {
if (JDWMinIE4) layer.style.visibility = "inherit";
}

function getVisibility(layer) {
if (JDWMinIE4)return layer.style.visibility;
return "";
}

function moveLayerTo(layer, x, y) {
if (JDWMinIE4) {
layer.style.left = x;
layer.style.top  = y;   }
}

function moveLayerBy(layer, dx, dy) {
if (JDWMinIE4) {
layer.style.pixelLeft += dx;
layer.style.pixelTop  += dy;   }
}

function getLeft(layer) {
if (JDWMinIE4)return layer.style.pixelLeft;
return -1;
}

function getTop(layer) {
if (JDWMinIE4)return layer.style.pixelTop;
return -1;
}

function getRight(layer) {
if (JDWMinIE4)return layer.style.pixelLeft + getWidth(layer);
return -1;
}

function getBottom(layer) {
if (JDWMinIE4)return layer.style.pixelTop + getHeight(layer);
return -1;
}

function getPageLeft(layer) {
var x;
if (JDWMinIE4) {
x = 0;
while (layer.offsetParent != null) {
x += layer.offsetLeft;
layer = layer.offsetParent;}
x += layer.offsetLeft;
return x;}
return -1;
}

function getPageTop(layer) {
var y;
if (JDWMinIE4) {
y = 0;
while (layer.offsetParent != null) {
y += layer.offsetTop;
layer = layer.offsetParent;}
y += layer.offsetTop;
return y;}
return -1;
}

function getWidth(layer) {
if (JDWMinIE4) {
if (layer.style.pixelWidth)return layer.style.pixelWidth;
else return layer.clientWidth;}
return -1;
}

function getHeight(layer) {
if (JDWMinIE4) {
if (layer.style.pixelHeight)return layer.style.pixelHeight;
else return layer.clientHeight;}
return -1;
}

function getzIndex(layer) {
if (JDWMinIE4)return layer.style.zIndex;
return -1;
}

function setzIndex(layer, z) {
if (JDWMinIE4)layer.style.zIndex = z;
}

function clipLayer(layer, clipleft, cliptop, clipright, clipbottom) {
if (JDWMinIE4)layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')';
}

function getClipLeft(layer) {
if (JDWMinIE4) {
var str =  layer.style.clip;
if (!str)return 0;
var clip = getIEClipValues(layer.style.clip);
return(clip[3]);}
return -1;
}

function getClipTop(layer) {
if (JDWMinIE4) {
var str =  layer.style.clip;
if (!str)return 0;
var clip = getIEClipValues(layer.style.clip);
return clip[0];}
return -1;
}

function getClipRight(layer) {
if (JDWMinIE4) {
var str =  layer.style.clip;
if (!str)return layer.style.pixelWidth;
var clip = getIEClipValues(layer.style.clip);
return clip[1];}
return -1;
}

function getClipBottom(layer) {
if (JDWMinIE4) {
var str =  layer.style.clip;
if (!str)return layer.style.pixelHeight;
var clip = getIEClipValues(layer.style.clip);
return clip[2];}
return -1;
}

function getClipWidth(layer) {
if (JDWMinIE4) {
var str = layer.style.clip;
if (!str)return layer.style.pixelWidth;
var clip = getIEClipValues(layer.style.clip);
return clip[1] - clip[3];}
return -1;
}

function getClipHeight(layer) {
if (JDWMinIE4) {
var str =  layer.style.clip;
if (!str)return layer.style.pixelHeight;
var clip = getIEClipValues(layer.style.clip);
return clip[2] - clip[0];}
return -1;
}

function getIEClipValues(str) {
var clip = new Array();
var i;
i = str.indexOf("(");
clip[0] = parseInt(str.substring(i + 1, str.length), 10);
i = str.indexOf(" ", i + 1);
clip[1] = parseInt(str.substring(i + 1, str.length), 10);
i = str.indexOf(" ", i + 1);
clip[2] = parseInt(str.substring(i + 1, str.length), 10);
i = str.indexOf(" ", i + 1);
clip[3] = parseInt(str.substring(i + 1, str.length), 10);
return clip;
}

function scrollLayerTo(layer, x, y, bound) {
var dx = getClipLeft(layer) - x;
var dy = getClipTop(layer) - y;
scrollLayerBy(layer, -dx, -dy, bound);
}

function scrollLayerBy(layer, dx, dy, bound) {
var cl = getClipLeft(layer);
var ct = getClipTop(layer);
var cr = getClipRight(layer);
var cb = getClipBottom(layer);
if (bound) {
if (cl + dx < 0)dx = -cl;
else if (cr + dx > getWidth(layer))dx = getWidth(layer) - cr;
if (ct + dy < 0)dy = -ct;
else if (cb + dy > getHeight(layer))dy = getHeight(layer) - cb;}
clipLayer(layer, cl + dx, ct + dy, cr + dx, cb + dy);
moveLayerBy(layer, -dx, -dy);
}

function setBgColor(layer, color) {
if (JDWMinIE4)layer.style.backgroundColor = color;
}

function getLayer(name) {
if (JDWMinIE4)return eval('document.all.' + name);
return null;
}

function findLayer(name, doc) {
var i, layer;
for (i = 0; i < doc.layers.length; i++) {
layer = doc.layers[i];
if (layer.name == name)return layer;
if (layer.document.layers.length > 0)
if ((layer = findLayer(name, layer.document)) != null)
return layer;}
return null;
}

function getWindowWidth() {
if (JDWMinIE4)return document.body.clientWidth;
return -1;
}

function getWindowHeight() {
if (JDWMinIE4)return document.body.clientHeight;
return -1;
}

function getPageWidth() {
if (JDWMinIE4)return document.body.scrollWidth;
return -1;
}

function getPageHeight() {
if (JDWMinIE4)return document.body.scrollHeight;
return -1;
}

function getPageScrollX() {
if (JDWMinIE4)return document.body.scrollLeft;
return -1;
}

function getPageScrollY() {
if (JDWMinIE4)return document.body.scrollTop;
return -1;
}

var JDWITEMs = new Array();    

function ITEM(text, link) {
this.text = text;    
this.link = link;    
}


function ECSmenu(hdrWidth, menuWidth) {
this.hdrWidth  = hdrWidth;
this.width     = menuWidth;
this.height    = 0;
this.items = new Array();
this.addItem = ECSmenuaddItem;
}


function ECSmenuaddItem(item) {
this.items[this.items.length] = item;
}


function JDWITEM(width) {
this.x = 0;
this.y = 0;
this.width  = width;
this.height = 0;
this.align    = "left";
this.minWidth = 0;
this.inverted = false;
this.menus = new Array();
this.created = false;
this.border    = 2;
this.padding   = 4;
this.separator = 1;
this.setSizes    = JDWITEMSetSizes;
this.setColors   = JDWITEMSetColors;
this.setFonts    = JDWITEMSetFonts;
this.addNAVm     = JDWITEMaddNAVm;
this.create      = JDWITEMCreate;
this.hide        = JDWITEMHide;
this.show        = JDWITEMShow;
this.moveTo      = JDWITEMMoveTo;
this.moveBy      = JDWITEMMoveBy;
this.getzIndex   = JDWITEMGetzIndex;
this.setzIndex   = JDWITEMSetzIndex;
this.getWidth    = JDWITEMGetWidth;
this.getMinWidth = JDWITEMGetMinWidth;
this.getAlign    = JDWITEMGetAlign;
this.setAlign    = JDWITEMSetAlign;
this.resize      = JDWITEMResize;
this.invert      = JDWITEMInvert;
this.isInverted  = JDWITEMIsInverted;
this.index = JDWITEMs.length;
JDWITEMs[this.index] = this;
}

function JDWITEMSetSizes(border, padding, separator) {
if (!this.created) {
this.border = border;
this.padding = padding;
this.separator = separator;   }
}

function JDWITEMSetColors(bdColor,hdrFgColor, hdrBgColor, hdrHiFgColor, hdrHiBgColor,itmFgColor, itmBgColor, itmHiFgColor, itmHiBgColor) {
if (!this.created) {
this.borderColor  = bdColor;
this.hdrFgColor   = hdrFgColor;
this.hdrBgColor   = hdrBgColor;
this.hdrHiFgColor = hdrHiFgColor;
this.hdrHiBgColor = hdrHiBgColor;
this.itmFgColor   = itmFgColor;
this.itmBgColor   = itmBgColor;
this.itmHiFgColor = itmHiFgColor;
this.itmHiBgColor = itmHiBgColor;  }
}

function JDWITEMSetFonts(hdrFamily, hdrStyle, hdrWeight, hdrSize,itmFamily, itmStyle, itmWeight, itmSize) {
if (!this.created) {
this.hdrFontFamily = hdrFamily;
this.hdrFontStyle  = hdrStyle;
this.hdrFontWeight = hdrWeight;
this.hdrFontSize   = hdrSize;
this.itmFontFamily = itmFamily;
this.itmFontStyle  = itmStyle;
this.itmFontWeight = itmWeight;
this.itmFontSize   = itmSize;   }
}

function JDWITEMaddNAVm(menu) {
if (!this.created)this.menus[this.menus.length] = menu;
}

function JDWITEMCreate() {
var str;
var i, j;
var norm, high, end;
var width, height;
var x, y;
var scrX, scrY;
if (this.created || ( !JDWMinIE4))return;
str = "";
if (JDWMinIE4 && !JDWMinIE5) {
scrX = getPageScrollX();
scrY = getPageScrollY();
window.scrollTo(getPageWidth(), getPageHeight());}
if (JDWMinIE4)
str += '<div id="JDWITEM' + this.index + '_filler"'+  ' style="position:absolute;">'+  '</div>\n'+  '<div id="JDWITEM' + this.index + '_hdrsBase"'+  ' style="position:absolute;">\n';
for (i = 0; i < this.menus.length; i++) {
norm = '<table border=0 cellpadding=' + this.padding+ ' cellspacing=0'+ (this.menus[i].hdrWidth > 0 ? ' width=' + this.menus[i].hdrWidth : '')+ ((JDWMinIE4 && !JDWMinIE5) ? ' id="JDWITEM' + this.index + '_tbl' + i + '"': '')+ '><tr><td'+ (this.menus[i].hdrWidth == 0 ? ' nowrap=1' + this.menus[i].hdrWidth : '')+ '>'+ '<span style="color:' + this.hdrFgColor + ';'+ 'font-family:' + this.hdrFontFamily + ';'+ 'font-size:' + this.hdrFontSize + ';'+ 'font-style:' + this.hdrFontStyle + ';'+ 'font-weight:' + this.hdrFontWeight + ';">';
high = '<table border=0 cellpadding=' + this.padding+ ' cellspacing=0'+ (this.menus[i].hdrWidth > 0 ? ' width=' + this.menus[i].hdrWidth : '')+ '><tr><td'+ (this.menus[i].hdrWidth == 0 ? ' nowrap=1' + this.menus[i].hdrWidth : '')+ '>'+ '<span style="color:' + this.hdrHiFgColor + ';'+ 'font-family:' + this.hdrFontFamily + ';'+ 'font-size:' + this.hdrFontSize + ';'+ 'font-style:' + this.hdrFontStyle + ';'+ 'font-weight:' + this.hdrFontWeight + ';">';
end  = '</span></td></tr></table>';
if (JDWMinIE4) {
str += '<div id="JDWITEM' + this.index + '_head' + i + '"'+  ' style="position:absolute;">'+  norm + this.menus[i].items[0].text + end+  '</div>\n'+  '<div id="JDWITEM' + this.index + '_headHigh' + i + '"'+  ' style="position:absolute;">'+  high + this.menus[i].items[0].text + end+  '</div>\n'+  '<div id="JDWITEM' + this.index + '_headDummy' + i + '"'+  ' style="position:absolute;">';
str += '</div>\n';   }
}

if (JDWMinIE4) {
str += '</div>\n';
str = '<div id="JDWITEM' + this.index + '"'+ ' style="position:absolute;left:0px;top:0px;">\n'+ str+ '</div>\n';
document.body.insertAdjacentHTML("beforeEnd", str);
this.baseLayer = getLayer("JDWITEM" + this.index);
}

width = 0;
height = 0;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -