Forum Discussion

FrankMartin1610's avatar
FrankMartin1610
Copper Contributor
Sep 17, 2023
Solved

Disable contextmenu (right click) in Media Web Part

I want to disable contextmenu (right click) in Media Web Part so user cannot download video file. Found solution here which I tested in browser by inspecting element and updating HTML and it worked.

 

https://sharepoint.stackexchange.com/questions/147180/remove-save-as-and-copy-video-url-in-media-web-part

 

Solution is to write code oncontextmenu="return false;" in video control.

 

My question is how do I actually update code permanently and not just in inspect element/developer tools because on page refresh, the code is gone.

  • Added a script web part on page and wrote following code to stop context menu from appearing.

    <script>
      document.querySelector('video').setAttribute('oncontextmenu', "return false;");
    </script>

1 Reply

  • FrankMartin1610's avatar
    FrankMartin1610
    Copper Contributor

    Added a script web part on page and wrote following code to stop context menu from appearing.

    <script>
      document.querySelector('video').setAttribute('oncontextmenu', "return false;");
    </script>

Resources