Last active
August 29, 2015 14:10
-
-
Save songfei1983/ff11bd3954366a2c5bb1 to your computer and use it in GitHub Desktop.
よくWebOSやJSで禁止されるキー設定 ref: http://qiita.com/songfei1983/items/f8d5fde5709c74c6b5f5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var event = e || window.event; | |
var k = event.keyCode; | |
if((event.ctrlKey == true && k == 82) || (event.ctrlKey == true && k == 78) || (k == 116) || (event.ctrlKey == true && k == 116)) | |
{ | |
event.keyCode = 0; | |
event.returnValue = false; | |
event.cancelBubble = true; | |
return false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.oncontextmenu = function(){ | |
return false; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.ondragstart = function(){ | |
return false; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.onselectstart = function( e ){ | |
var event = e || window.event; | |
var tagName = ''; | |
try{ | |
tagName = (event.target || event.srcElement).tagName.toLowerCase(); | |
} | |
catch(e){} | |
if( tagName != 'textarea' && tagName != 'input'){ | |
return false; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.onclick = function( e ){ | |
//Shift + click 及び Ctrl + click を禁止 | |
var event = e || window.event; | |
var tagName = ''; | |
try{ | |
tagName = (event.target || event.srcElement).tagName.toLowerCase(); | |
} | |
catch(e){} | |
if( (event.shiftKey || event.ctrlKey) && tagName == 'a' ){ | |
event.keyCode = 0; | |
event.returnValue = false; | |
event.cancelBubble = true; | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment