Skip to content

Instantly share code, notes, and snippets.

@phillipalexander
Forked from Kilian/annoying.js
Created August 8, 2013 23:46
Show Gist options
  • Save phillipalexander/6189890 to your computer and use it in GitHub Desktop.
Save phillipalexander/6189890 to your computer and use it in GitHub Desktop.
//make sure the browser window is 'maximised'
window.resizeTo(1024,768);
//no context menu
document.oncontextmenu = function(){return false}
//no loading in iframes
if (parent.frames.length > 0) top.location.replace(document.location);
//no dragging
document.ondragstart = function(){return false}
//no text selection, in IE
document.onselectstart=function(){
if (event.srcElement.type != "text" && event.srcElement.type != "textarea" && event.srcElement.type != "password") {
return false
} else {
return true;
}
};
//no text selection, in Firefox
document.onmousedown=function(e){
var obj=e.target;
if (obj.tagName.toUpperCase() == "INPUT" || obj.tagName.toUpperCase() == "TEXTAREA" || obj.tagName.toUpperCase() == "PASSWORD") {
return true;
} else {
return false;
}
}
//prompt when the user leaves your page
window.onunload=function() {
function dontLeave() {
alert("Please come back!!1");
}
dontLeave();
}
//prevent user from copying or pasting text
window.onkeydown = function(e) {
if (e.ctrlKey == true) {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment