we can open browsers dev console using:
F12
, Ctrl+Shift+C
, Ctrl+Shift+I
and ...
i have prevented from right click and those keys using this code:
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
});
document.onkeydown = function(e) {
if(event.keyCode == 123) {
console.log('You cannot inspect Element');
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {
console.log('You cannot inspect Element');
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {
console.log('You cannot inspect Element');
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {
console.log('You cannot inspect Element');
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {
console.log('You cannot inspect Element');
return false;
}
}
// prevents right clicking
document.addEventListener('contextmenu', e => e.preventDefault());
now imagine the dev console is already opened and our page is loading after it, i want to close this dev console windows using programmatically with javascript, when the page is loaded. is this possible??