Mình thấy cài nhiều Add-on như này sẽ dễ làm xung đột code, nên mình đã sử dụng Css và js như bạn thanhhai nói để thực hiện. Bằng cách sử dụng Google tags sẽ đơn giản hơn nhiều.
Các bạn có thể test chức năng này ở
diễn đàn sinh viên thẩm định giá
HTML:
<style>
body {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
</style>
<script type="text/javascript">
document.onkeypress = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
return false;
}
};
document.onmousedown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
return false;
}
};
document.onkeydown = function(event) {
event = (event || window.event);
if (event.keyCode === 123) {
return false;
}
};
function contentprotector() {
return false;
}
function mousehandler(e) {
var myevent = (isNS) ? e : event;
var eventbutton = (isNS) ? myevent.which : myevent.button;
if ((eventbutton === 2) || (eventbutton === 3))
return false;
}
document.oncontextmenu = contentprotector;
document.onmouseup = contentprotector;
var isCtrl = false;
window.onkeyup = function(e)
{
if (e.which === 17)
isCtrl = false;
}
window.onkeydown = function(e)
{
if (e.which === 17)
isCtrl = true;
if (((e.which === 85) || (e.which === 65) || (e.which === 88) || (e.which === 67) || (e.which === 86) || (e.which === 83)) && isCtrl === true)
{
return false;
}
}
isCtrl = false;
document.ondragstart = contentprotector;
</script>