菜单示例:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript" src="js/popup-menu.js"></script>
<script language="JavaScript">
function checkMenu(ev) {
var el = Menu.is_ie ? Menu.getElement(ev) : Menu.getTargetElement(ev);
for (; el != null; el = el.parentNode)
// FIXME: allow end-user to click some link without closing the
// calendar. Good to see real-time stylesheet change :)
if (el.tagName=='DIV'||el.tagName=='A') break;
if (el == null) {
// calls closeHandler which should hide the calendar.
hideMenu();
Menu.stopEvent(ev);
}
}
function showMenu(ev){
var el = Menu.getElement(ev);
if(Menu.timeout)clearTimeout(Menu.timeout);
//var el=document.getElementById(id);
if (el.menu != null) {
el.menu.hide();
}
el.menu.showAtElement(el); // show the calendar below it
// catch "mousedown" on document
Menu.addEvent(document, "mouseover", checkMenu);
//return false;
}
function hideMenu(ev){
var el = Menu.getElement(ev);
if(Menu.timeout)clearTimeout(Menu.timeout);
// if (el==null || el.menu == null || el.menu!=Menu._M) {
Menu.timeout=setTimeout("Menu.hide()",250);
//}
}
function showMenuAt(m,id){
var el=document.getElementById(id);
el.menu=m;
Menu.addEvent(el,"mouseover",showMenu);
Menu.addEvent(el,"mouseout",hideMenu);
}
</script>
<style type="text/css">
div.popup-menu { position: relative; }
.popup-menu, .popup-menu table {
font-size: 14px;
color: #000;
cursor: default;
background-color: #759704;
}
.popup-menu thead .headrow { /* This holds the current "month, year" */
font-weight: bold; /* Pressing it will take you to the current date */
text-align: center;
padding: 2px;
background: #89DA81;
color: #232364;
}
.popup-menu thead .hilite { /* How do the buttons in header appear when hover */
background: #afa;
color: #000;
border: 1px solid #084;
padding: 1px;
}
Menu.prototype.destroy = function () {
var el = this.element.parentNode;
el.removeChild(this.element);
delete el;
};
Menu.prototype.add = function(text,href,target,title){
this.items[this.count++]=new MenuItem(text,href,target,title);
}
Menu.prototype.show = function () {
if(Menu._M)Menu._M.hide;
this.element.style.display = "block";
this.hideShowCovered();
Menu._M=this;
};
Menu.prototype.hide = function () {
this.element.style.display = "none";
};
Menu.prototype.showAt = function (x, y) {
var s = this.element.style;
s.left = x + "px";
s.top = y + "px";
this.show();
};
Menu.prototype.showAtElement = function (el) {
var p = Menu.getAbsolutePos(el);
this.showAt(p.x + el.offsetWidth, p.y+5);
};
Menu.prototype.hideShowCovered = function () {
var tags = new Array ('applet', 'iframe', 'select');
var el = this.element;
var p = Menu.getAbsolutePos(el);
var EX1 = p.x;
var EX2 = el.offsetWidth + EX1;
var EY1 = p.y;
var EY2 = el.offsetHeight + EY1;
for (var k = 0; k < tags.length; k++) {
var ar = document.getElementsByTagName(tags[k]);
var cc = null;
for (var i = 0; i < ar.length; i++) {
cc = ar[i];
p = Menu.getAbsolutePos(cc);
var CX1 = p.x;
var CX2 = cc.offsetWidth + CX1;
var CY1 = p.y;
var CY2 = cc.offsetHeight + CY1;
As of Microsoft® Internet Explorer 5.5, the iframe object is windowless and supports the zIndex property. In earlier versions of Internet Explorer, the iframe object is windowed and, like all windowed controls, ignores the zIndex property. If you maintain Web pages that were designed for earlier versions of Internet Explorer that do not support the zIndex property, you might want to redesign the pages, especially if the pages contain iframe objects that are stacked on top of windowed controls, such as select objects. You can use the visibility attribute to hide windowed controls that you want an iframe object to overlap. You can also position windowed controls so that iframe objects do not overlap them.