所以我们都知道,一旦你发布你的图像,你就无法真正保护你的图像,但是对于那些非专业人士来说,它有点乐趣。我添加了一个脚本以防止右键单击并试图随机化有趣的消息......它无法正常工作。
脚本:
// BACKGROUND IMAGES
try {
document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}
// no right click
var message=["That doesn't belong to you! Put the mouse down and no one gets hurt!";
"Oh, you again. We of the internet have chosen to defy you!";
"How would you like it if I walked into your house and tried to help myself to your furniture?";
"Hey that tickles!"
"Thief! You are being directed to the... nah just kidding. Enjoy!"]
function clickIE4(){
if (event.button==2){
alert(message);
return false;
}
}
function clickNS4(e){
if (document.layers||document.getElementById&&!document.all){
if (e.which==2||e.which==3){
alert(message);
return false;
}
}
}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=clickNS4;
}
else if (document.all&&!document.getElementById){
document.onmousedown=clickIE4;
}
document.oncontextmenu=new Function("alert(message);return false")
我忘记了什么?它看起来应该有效。当我删除[和]并将其减少为一条消息时,该消息正常工作。它当我添加额外的并尝试随机化它以解决问题。
答案 0 :(得分:2)
你警告整个阵列 如果您想要随机消息,您可以执行以下操作:
var rn = Math.floor(Math.random() * message.length);
alert(message[rn]);
这会从数组中的消息数中生成一个随机数。