Free add menu, similar to those small menus in the eBay. JavaScript implementation, can span multiple browsers

xiaoxiao2021-03-06  40

Similar to those small drop-down menus in "My Easy" in eBay.

Implement with JavaScirpt,

Support multi-browser, debugging in IE6 and Firefox)

The following is the code in Menu.js

Var arymenu = new array ();

Var vView;

Var vhide;

Var menudiv;

IF (Window.navigator.Appname.indexof ("ICROSoft")> = 1) {

VHIDE = "hidden";

vview = "visible";

}

Else {

vhide = "hide";

vview = "show";

}

Function addmenu (menuid) {

Arymenu [Menuid] = New Array ();

}

Function addLink (Menuid, Strlink, Strtext) {

AddMenuhtml (Menuid, Strlink, "" strText "");

}

Function AddMenuhtml (Menuid, Strlink, strHtml) {

Arymenu [Menuid] [strlink] = strHTML;

}

Function MenuView (Menuid, thisevt) {

IF (Document.all) {

Menudiv = Document.all ["Menulayer"];

}

Else {

Menudiv = Document.GtelementByid ("Menulayer");

}

Var strHtml = "

"

FOR (VAR strlink in arymenu [menuid]) {

Strhtml = strHtml "

" arymenu [menuid] [strlink] " ";

}

Strhtml = strHtml "";

Menudiv.innerhtml = strHTML;

DivView (thisevt);

}

Function Check_Mouse (thisevt) {

VAR CX;

Var cy;

Var Divobj;

IF (Document.all) {

CX = Document.body.scrollleft window.event.clientX;

CY = Document.body.scrolltop window.event.clienty;

}

Else {

Cx = trisevt.pagex;

Cy = trisevt.pagey;

}

IF (cx menudiv.offsetleft menudiv.offsetwidth || CY menudiv.offsettop menudiv.offsetHeight) {

IF (Menudiv.style) {divobj = menudiv.style; vHide = "hidden";} else {divobj = menudiv; vHide = "hide";} Divobj.visibility = "hidden";

Document.οnmοusemοve = null;

}

}

Function DivView (thisevt) {

VAR CX;

Var cy;

Var Divobj;

IF (Document.all) {

CX = Document.body.scrollleft window.event.clientX-80;

Cy = document.body.scrolltop window.event.clienty-10;

}

Else {

Cx = trisevt.pagex-80;

Cy = trisevt.pagey-10;

}

While (cx

While (cy

While (cy> document.body.offsetheight document.body.scrolltop-menudiv.offsetheight) {cy -}

IF (Menudiv.style) {divobj = menudiv.style; vView = "visible";} else {divobj = menudiv; vView = "show";

Divobj.Left = CX;

Divobj.top = cy;

Divobj.visibility = vView;

Document.οnmοusemοve = check_mouse;

}

AddMenubtn (Menuid) {

Document.writeln ("");

}

Document.writeln ("

");

Join between between the page you need to use