Доброе время суток. На страничке имеется кнопка. При нажатии на кнопку появляется, что то вроде всплывающей посказки(div), с линками - "подменю". При нажатии на пустое место дива я скрываю видимость подменю. Также при нажатии на один из линков подменю, скрываю видимость дива(подменю). Проблема в том, что этот самый див не исчезает после первого раза. Тоесть он всегда остается на экране. | Код | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Untitled Page</title> <script language="javascript"> function func1() { //blabla } function func2() { //blabla } function hidePopupMenu() { try { var currActionPopupMenu = document.getElementById("actionPopupDiv"); currActionPopupMenu.style.display = "none"; currActionPopupMenu.innerHTML = ""; currActionPopupMenu.style.top = 0; currActionPopupMenu.style.left = 0; currActionPopupMenu.style.zIndex = "0"; } catch(e) { } } function showActionPopupMenu() { //debugger; hidePopupMenu(); // create links for popup menu var linkset = new Array(); linkset[0] = "<TABLE width='100%' border='1px' cellpadding='0' cellspacing='0'><TR onclick='hidePopupMenu()'><TD><a href='#' onclick='func1();hidePopupMenu();'>function1</a></TD></TR><TR onclick='hidePopupMenu()'><TD><a href='#' onclick='func2();hidePopupMenu();'>function2</a></TD></TR></TABLE>"; // create popup div var oPopupActionDiv = document.createElement("div"); oPopupActionDiv.id = "actionPopupDiv"; oPopupActionDiv.attachEvent("onclick",hidePopupMenu); // set styles for popup div menu oPopupActionDiv.style.visibility = "hidden"; oPopupActionDiv.style.position = "absolute"; oPopupActionDiv.style.left = "0"; oPopupActionDiv.style.top = "0"; oPopupActionDiv.style.borderStyle = "solid"; oPopupActionDiv.style.borderColor = "#000000"; oPopupActionDiv.style.borderWidth = "1px"; oPopupActionDiv.style.width = "110px"; oPopupActionDiv.style.height = "40px"; oPopupActionDiv.style.backgroundColor = "#f5f5f5"; oPopupActionDiv.style.padding = "0px"; oPopupActionDiv.style.zIndex = "1000"; // append links to popup div oPopupActionDiv.innerHTML = linkset[0]; oPopupActionDiv.style.left = window.event.clientX - 55; oPopupActionDiv.style.top = window.event.clientY - 55; oPopupActionDiv.style.visibility = "visible"; // append div to the document document.body.appendChild(oPopupActionDiv); } </script> </head> <body> <br /> <br /> <br /><br /><br /><br /><br /><br /><br /><br /> <center> <!-- create button that show popup menu by click --> <input type="button" onclick="showActionPopupMenu()" value="click Me" /> </center> </body> </html>
|
Что я делаю не так ?
|