Click here to Skip to main content
15,745,574 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i wanted to create a context menu for my website so my customers can get a menu that can control the website.

i need it for my website

What I have tried:

i have tried doing the js method and searching up js ways to create a context menu.
Updated 8-Jun-22 13:38pm

1 solution

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

    <!DOCTYPE html>

    	<style type="text/css">
    		.context-menu {
    			position: absolute;
    			text-align: center;
    			background: lightgray;
    			border: 1px solid black;

    		.context-menu ul {
    			padding: 0px;
    			margin: 0px;
    			min-width: 150px;
    			list-style: none;

    		.context-menu ul li {
    			padding-bottom: 7px;
    			padding-top: 7px;
    			border: 1px solid black;

    		.context-menu ul li a {
    			text-decoration: none;
    			color: black;

    		.context-menu ul li:hover {
    			background: darkgray;


      right click in the run-code

    	<div id="contextMenu" class="context-menu"
    			<li><element onclick="report()">Report Feedback</element></li>
    			<li><element onclick>Element</element></li>
    			<li><element >Element</element></li>
    			<li><element >Element</element></li>
    			<li><element >Element</element></li>
    			<li><element >Element</element></li>
    			<li><element >Element</element></li>
                <li><element >Element</element></li>
                <li><element >Element</element></li>
                <li><element >Element</element></li>

    		document.onclick = hideMenu;
    		document.oncontextmenu = rightClick;

    		function hideMenu() {
    			document.getElementById("contextMenu").style.display = "none"

    		function rightClick(e) {

    			if (document.getElementById("contextMenu").style.display == "block")
    			else {
    				var menu = document
    				 = 'block'; = e.pageX + "px"; = e.pageY + "px";
          function report() {
              let report = prompt("send feedback");
              alert("your request was sent.")


<!-- end snippet -->
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900