Forum Moderators: open
i am new to javascript
pl help me how to protect my js code
regards
Well, you could create a long list of .js files:
In your document:
<script>
document.write("<scr" + "ipt " + " sr" + "c=\"bo" + "b.js\"" + "> </script>");
</script> And in bob.js put another long line of compucated code linking to another .js file etc until you reach the js document reaching the javascript code. Alas the thief could just link to bob.js but just put credits in. He gets the code, you get advertising!
Alternatively block the right click - place this in the head tag:
<script>
<!-- var debug = true;
function right(e) {
if (navigator.appName == 'Netscape' && (e.which == 3 ¦¦ e.which == 2)) return false;
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 ¦¦ event.button == 3)) {
alert('Why are you bothering?');
return false;
}
return true;
}
document.onmousedown=right;
if (document.layers) window.captureEvents(Event.mousedown);
window.onmousedown=right;
//-->
</script> Well there you go!
cmatcme
<script language="javascript">
<!--
function rightguard() {
if (event.button==2) {
alert('Do not bother')
}
}
document.onmousedown=rightguard
//-->
</script> Place that in the head tag. You can change alert() to another command like confirm().
Click here for more scripts [google.com]
Sorry!
cmatcme