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.
//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, then never letting them go.
window.onunload=function() {
function dontLeave() {
if(confirm("Are you sure you want to leave?")) {
dontLeave();
} else {
dontLeave();
}
}
dontLeave();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment