點選開啟選單
document.getElementById("myMenu").onmouseout = closeMenu;
function openMenu(event, id) {
var el, x , y;
el = document.getElementById(id);
if (window.event) {
x = window.event.clientX document.documentElement.scrollLeft
document.body.scrollLeft
document.body.scrollLeft
document.body.scrollLeft
document.body.scrollLeft
document.body.scrollLeft
我; 🎜>y = window.event.clientY document.documentElement.scrollTop
document.body.scrollTop;
}
else {
x = event.clientX window.scrollX . .clientY window.scrollY;
}
x -= 2; y - = 2;
el.style.left = x "px";
el.style.top = y "px" ;
el.style.visibility = "可見";
}
function closeMenu(event) {
var 目前,相關;
if (window.event) {
current = this;
相關= window.event.toElement;
}
else {
current = event.currentTarget;
相關=事件.相關目標;
}
if (當前!= 相關&& !contains(當前, 相關))
current.style.visibility = "隱藏";
}
function contains(a, b) {
// 如果節點a 包含節點b,則傳回true。
while (b.parentNode)
if ((b = b.parentNode) == a)
回傳true;
回傳錯誤;
}
td>