0

When I right click on a js canvas, the refresh page button is not available, is it possible to get the normal menu to pop up?

microsoft edge right clicked

Here is an example

<!DOCTYPE html>
<html>

<head>
  <title>Simple Drawing Program</title>
  <style>
    #canvas {
      border: 1px solid black;
    }
  </style>
</head>

<body>
  <canvas id="canvas" width="500" height="500"></canvas>

  <script>
    // Get the canvas element
    const canvas = document.getElementById('canvas');
    const context = canvas.getContext('2d');
  </script>
</body>

</html>

5
  • 1
    It's not missing - 'refresh' was never a standard context menu option of a canvas element. Why do you believe it should be? Commented Jul 11, 2023 at 13:51
  • I just need to be able to let the user refresh the page for the context I'm using it for and I was wondering if there was a hack to be able to have the option to refresh the page when they right click on a canvas Commented Jul 11, 2023 at 13:57
  • Are you listening for events on the canvas element? Commented Jul 11, 2023 at 14:00
  • You could add a button to the canvas which refreshes the page. However, I'd argue that any logic which requires the page to be refreshed is indicative of a poor design. If the data in the page is expected to change while the user is viewing it, then update the content dynamically using AJAX/sockets/web workers etc Commented Jul 11, 2023 at 14:00
  • its for a project where the canvas will be fullscreen for a creative coding project. sometimes it needs to be refreshed to stop lag and the webpage is run in a program that doesn't have access to the refresh icon or f5 shortcut. I don't want to add a button so it can just be a fullscreen visual thing, should I just overwrite the right click with a custom menu with a refresh button? or is there a simpler way Commented Jul 11, 2023 at 14:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.