Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[分享] discuz程序html5视频禁止右键下载的方法

[复制链接]
KINGTHING 发表于 2020-1-15 20:40:56 | 显示全部楼层 |阅读模式
帖子播放页面代码如下:
  1. <video id="video1" class="video-js" controls="" preload="auto" controlslist="nodownload" width="{$vwidth}" height="{$vheight}" >
  2.     <source src="{$attach_url}" type="video/mp4">
  3.     <p>浏览器不支持HTML5视频播放</p>
  4.   </video>
  5.    <script type="text/javascript">
  6. var myVideo=document.getElementById("video1");
  7. jQuery('#video1').bind('contextmenu',function() { return false; });
  8. </script>
复制代码
另需在页面header_common.htm中找到
  1. <script type="text/javascript" src="{$_G[setting][jspath]}common.js?{VERHASH}"></script>
复制代码
在他之前引入
  1. <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
复制代码
另外,如需完全屏蔽网页右键选项可在页面底部添加如下代码:
  1. <script language="JavaScript">
  2. <!--

  3. if (window.Event)
  4. document.captureEvents(Event.MOUSEUP);

  5. function nocontextmenu()
  6. {
  7. event.cancelBubble = true
  8. event.returnValue = false;

  9. return false;
  10. }

  11. function norightclick(e)
  12. {
  13. if (window.Event)
  14. {
  15. if (e.which == 2 || e.which == 3)
  16. return false;
  17. }
  18. else
  19. if (event.button == 2 || event.button == 3)
  20. {
  21. event.cancelBubble = true
  22. event.returnValue = false;
  23. return false;
  24. }

  25. }

  26. document.oncontextmenu = nocontextmenu; // for IE5+
  27. document.onmousedown = norightclick; // for all others
  28. //-->
  29. </script>
复制代码
演示地址:http://moxingtu.com/thread-239-1-1.html
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-5-18 07:22 , Processed in 0.087960 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表