javascript implements the method of popup hidden menu by clicking the left button anywhere in the web page

  • 2020-06-12 08:25:51
  • OfStack

In fact, JS controls the display of THE DIV layer. The DIV layer is nested with a table in which there are menus. In this way, it is easy to modify


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> The hidden menu </title>
<style type="text/css">
body {
 font: 9pt;
}
.box {
 font: 9pt " Song typeface ";
 position: absolute;
 background: skyblue;
}
</style>
</head>
<body>
<table cellpadding="5" id="itemopen" class="box" style="display:none">
 <tr>
  <td bgcolor="#0066cc"> Website navigation: </td>
 </tr>
<tr>
  <td><a href="/">AJAX The instance </a></td>
 </tr>
 <tr>
  <td><a href="/jscss/">jQuery related </a></td>
 </tr>
 <tr>
  <td><a href="/jscss/">ExtJS demo </a></td>
 </tr>
</table>
</center>
</div>
<script language="JavaScript">
document.onclick = popUp 
function popUp() {
newX = window.event.x + document.body.scrollLeft
newY = window.event.y + document.body.scrollTop
menu = document.all.itemopen
 if ( menu.style.display == ""){
  menu.style.display = "none" }
 else {
   menu.style.display = ""}
  menu.style.pixelLeft = newX - 50
  menu.style.pixelTop = newY - 50
}
</script>
<body>
<p align="center"><font size="3"> Left click to see? </p>
</body>
</html>

Hopefully, this article has been helpful in your javascript programming.


Related articles: