Skip to navigation
JavaScript context menu when your right mouse click over a web content
28.02.25
Add a website JavaScript context menu when your right or left mouse click over a web content, same you see on most desktop applications ## Install ``` npm install jquery-contextmenu ``` ## Add CSS and JS to the webpage ```
``` ## My case example I added to a jgrid table ``` jQuery.contextMenu({ selector: ".contextmenu .ui-jqgrid-cell-wrapper", items: { copy: { name: "Copy", callback: function (key, opt) { const content = jQuery(this).text().trim(); navigator.clipboard.writeText(content).then( function () { log.info("Async: Copying to clipboard was successful!"); }, function (err) { log.info("Async: Could not copy text: ", err); }, ); }, }, foo: { name: "Go to Wiki for Details", callback: function (key, opt) { const content = jQuery(this).text().trim(); const col_name = jQuery(this).parent().attr("aria-describedby"); const url = "http://wiki.salamander-jewelry.net/index.php/Grid/" + page + "/" + col_name + "/" + content; window.open(url, "_blank").focus(); //console.log(url); //console.log(content); //console.log(col_name); //console.log(page); }, }, }, }); ```
https://swisnl.github.io/jQuery-contextMenu/docs.html
Reply
Anonymous
Information Epoch 1741794101
Live free or die.
Home
Notebook
Contact us