diff --git a/HTML/navbar.html b/HTML/navbar.html index 6dc7f11..f25e9c9 100644 --- a/HTML/navbar.html +++ b/HTML/navbar.html @@ -5,3 +5,42 @@ Fun Things +
+ diff --git a/JavaScript/main.js b/JavaScript/main.js index 6b21c0b..84e8854 100644 --- a/JavaScript/main.js +++ b/JavaScript/main.js @@ -7,3 +7,36 @@ var getCurrentDate = window.setInterval(function() { //window.onbeforeunload = function(){ // return 'Are you sure you want to leave?'; //}; + +// Right Click Menu +let rightClickMenu = document.getElementById("menu").style; +if (document.addEventListener) { + document.addEventListener('contextmenu', function(e) { + var posX = e.clientX; + var posY = e.clientY; + menu(posX, posY); + e.preventDefault(); + }, false); + document.addEventListener('click', function(e) { + rightClickMenu.display = "none"; + }, false); +} +else { + document.attachEvent('oncontextmenu', function(e) { + var posX = e.clientX; + var posY = e.clientY; + menu(posX, posY); + e.preventDefault(); + }); + document.attachEvent('onclick', function(e) { + setTimeout(function() { + rightClickMenu.display = "none"; + }, 501); + }); +} + +function menu(x, y) { + rightClickMenu.top = y + "px"; + rightClickMenu.left = x + "px"; + rightClickMenu.display = "block"; +}