Code to cancel the right mouse button on the front-end images of the site pages
To cancel the right mouse button click on the front-end images of the site pages in PHP, you can use JavaScript and CSS. However, PHP is a server-side language and doesn't have direct access to the client-side events. Here's an example of how you can achieve this using JavaScript and CSS: **HTML:** ```html <!DOCTYPE html> <html> <head> <title>Cancel Right Mouse Button Click</title> <link rel="stylesheet" href="style.css"> </head> <body> <img id="image" src="image.jpg" alt="Image"> <script src="script.js"></script> </body> </html> ``` **CSS (in style.css file):** ```css #image { cursor: pointer; } ``` **JavaScript (in script.js file):** ```javascript document.addEventListener('contextmenu', function(event) { event.preventDefault(); }); document.getElementById('image').addEventListener('contextmenu', function(event) { event.preventDefault(); }); ``` In the above code: 1. We add an event listener to the document to prevent the default context menu from appearing when the right mouse button is clicked. 2. We also add an event listener to the specific image element to prevent the default context menu from appearing when the right mouse button is clicked on that image. However, if you want to cancel the right mouse button click on all images on the page, you can use the following JavaScript code: ```javascript document.addEventListener('contextmenu', function(event) { if (event.target.tagName === 'IMG') { event.preventDefault(); } }); ``` This code checks if the target element of the context menu event is an image element, and if so, prevents the default context menu from appearing.