I want to put oncontextmenu='return false' in the video tag
Asked by DooHwan JIN:

We're using Confluence 5.9.  
I want to put oncontextmenu='return false' in the video tag to prevent the video right click. How can I put it in?

![image.png](/t5/image/serverpage/image-id/52920i58AC7438B45EA8A6/image-size/large?v=v2&px=999 "image.png")


Answers:
author: Shannon S
body: Hello JinDooHwan,

Thank you for reaching out! I'm happy to help.

I would recommend adding the text into your \<video tag itself:

    oncontextmenu="return false;"

You can also embed javascript on the page, like this:

     $(document).ready(function() {    $("video").bind("contextmenu",function(){        return false;        }); } );

This would prevent right-click on *any* video elements on that page. If you are unsure on how to add code to a Confluence page, have a look at [How to Use Javascript in Confluence](https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html).

One more thing that you need to be aware of, and this is very important. Your Confluence version of 5.9 reached [End of Life](https://confluence.atlassian.com/support/atlassian-support-end-of-life-policy-201851003.html) in November of 2017. It is at very high risk of being compromised, due to the following security advisories, explained below:

* **[Confluence Security Advisory - 2019-03-20 \| March 2019 Confluence Server Advisory - WebDAV and Widget Connector vulnerabilities](https://confluence.atlassian.com/doc/confluence-security-advisory-2019-03-20-966660264.html)**
* **[Confluence Security Advisory - 2019-04-17 \| Confluence - Path traversal vulnerability - CVE-2019-3398](https://confluence.atlassian.com/doc/confluence-security-advisory-2019-04-10-968660855.html)**

You'll need to make sure that you upgrade **as soon as possible** to the latest version of Confluence. For details on how to do that, have a look at our [Confluence Installation and Upgrade Guide](https://confluence.atlassian.com/doc/confluence-installation-and-upgrade-guide-214864161.html).

Thank you for your understanding!

Regards,

Shannon

comments: author: DooHwan JIN
body: **\<script type="text/javascript"\>**   
**$(document).ready(function() {**   
**$("video").bind("contextmenu",function(){**   
**return false;**   
**});**   
**} );**   
**\</script\>**

I put the code in Custom HTML.

But it doesn't work. Help me.


author: Shannon S
body: Hi there,

Thank you for following up!

I'm very sorry that I didn't include this in my example, but according to the document I sent you, [How to Use Javascript in Confluence](https://confluence.atlassian.com/confkb/how-to-use-javascript-in-confluence-313458839.html), you have to call AJS before any query.

I would recommend the [Multimedia Macro](https://confluence.atlassian.com/doc/multimedia-macro-228622735.html) for this, as it won't work the same if you're just using the attachments macro.

The script as follows:

```
<script type="text/javascript">
AJS.toInit(function(){
AJS.$("video").bind('contextmenu',function() { return false; });
});
</script>
```

Can you give that a try and let us know how it goes?

Regards,

Shannon


author: DooHwan JIN
body: ![#document.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/53654iEF0E963DDF6B3F18/image-size/large?v=v2&px=999 "#document.PNG")

Thank you for your answers.

It does not work in the #document.


author: DooHwan JIN
body: [@Shannon S](/t5/user/viewprofilepage/user-id/510046)

The method in confluence version 5.9 is required....


author: Shannon S
body: JinDooHwan,

The script has been tested to work with the multimedia macro, but it appears that from your script, you're trying to use an iFrame. Can you test using the Multimedia Macro and let me know how it goes?

Secondly, I would really advise against you remaining on version 5.9. It is imperative that you upgrade from the Confluence 5.9 version as soon as you possibly can. Your instance is at extreme risk until you upgrade.

Thank you for your understanding.

Regards,

Shannon


author: DooHwan JIN
body: [@Shannon S](/t5/user/viewprofilepage/user-id/510046)

We used multimedia macros.  
Script not applied.


author: Shannon S
body: From your reply, when you say "script not applied" I believe you mean that you did apply it, but it did not work as expected. Is this correct?

As we tested this to work on 6.6, I would recommend that you first do the upgrade as required, and then you can test the script again, and see if it works there.

Let us know if you have any trouble!

Regards,

Shannon


author: Luis Rodrigo Tayupanda
body: [@DooHwan JIN](/t5/user/viewprofilepage/user-id/1241650)

hello

if you solved this problem ..?

I have the same problem please help me...


Tags: atl-adm

confluence-server

server