PDA

View Full Version : Disable right mouse click script



foot_tsang
03-19-2015, 09:28 AM
1) Script Title: Disable right mouse click script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex9/noright2.htm

3) Describe problem:
This script works fine and stop all right click on image. As I do not want people to download my html5 mp4 video by right click and download, can this script be modified for stopping right click on video?

Thanks a lot!

ddadmin
03-19-2015, 11:15 PM
For HTML5 video, since it's implemented simply using the VIDEO tag, you can modify the script easily to also screen for that tag:


document.oncontextmenu = function(e){
var target = (typeof e !="undefined")? e.target: event.srcElement
if (target.tagName == "IMG" || target.tagName == "VIDEO" || (target.tagName == 'A' && target.firstChild.tagName == 'IMG'))
return false

}

Not sure about Flash based video players however.