Thursday, July 7, 2016

Cách khoá tải về đoạn phim bằng jQuery


Đây là html của 1 đoạn phim
<video id="video-hidden" width="320" height="240" controls>
  <source src="ThisIsMyVideo.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

<video width="320" height="240" controls>
  <source src="ThisIsMyVideo.mp4" type="video/mp4">
Your browser does not support the video tag.
</video>

Để đoạn phim ẩn, ta chèn thêm 1 id là video-hidden, nếu có thể này thì ngăn không cho người dùng chọn chuột phải tải video về bằng cách dùng jQuery sau:
<script type="text/javascript">
jQuery(document).ready(function(){
   jQuery('#video-hidden').bind('contextmenu',function() { return false; });
});
</script>

Chúc bạn thành công


EmoticonEmoticon