Is this safe to use to hide code from view code / inspect?
In an answer about as useful as the question,
"No".
Most of us can't read the code because it is packed/obfuscated, and won't invest the time to try to read it.
If you're asking if it will prevent the user from opening the Developer Tools, then I don't know, because that would require me trying to run the code, which I'm not going to do, since I can't read the code and it could be malicious.
If you're asking if it will prevent someone from obtaining the rest of the code on your website, then no, it will not. A determined user could use
curl
or one of several other tools to retrieve the raw HTML or Javascript.If you're asking if the code pasted above is secure because it is packed, then no, it is not. A determined user could quite easily analyze the code by hand and, once analyzed, write something to reverse engineer the packed code (that's assuming it uses an unknown packer -- if it uses a well-known packer, then someone has probably already written something to reverse it).
Is there a way to prevent the theft of a website's code?
One can never fully block a determined user from analyzing your code, only make things more annoying from them.
Simply using a minifier/uglifier on Javascript is usually enough to make the code mostly worthless to try to steal, since the cost of trying to analyze, rewrite it and further develop it is usually comparable to the cost of writing the same code from scratch.
How to hide html content from inspect element of developer tools?
You cannot secure your front-end, but you can certainly secure your server-side!
Good luck
how to hide html code when inspecting in codeigniter?
<script type="text/javascript">
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)){
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)){
return false;
}
}
Is it possible to remove Inspect Element?
It is possible to prevent the user from opening the context menu by right clicking like this (javascript):
document.addEventListener('contextmenu', function(e) {
e.preventDefault();
});
By listening to the contextmenu
event and preventing the default behavior which is "showing the menu", the menu won't be shown.
But the user will still be able to inspect code through the console (by pressing F12 in Chrome for example).
Related Topics
Accessing Private Member Variables from Prototype-Defined Functions
Switch Statement for Greater-Than/Less-Than
Alternation Operator Inside Square Brackets Does Not Work
Javascript/Jquery to Download File via Post with JSON Data
Defer Execution for Es6 Template Literals
How to Use Window.Postmessage Across Domains
How to Do a Horizontal Scroll on Mouse Wheel Scroll
Chrome Autofill/Autocomplete No Value for Password
How to Compare Colors in JavaScript
JavaScript Filter Array Multiple Conditions
Difference Between Knockout View Models Declared as Object Literals VS Functions
What Is the Correct Way to Check for String Equality in JavaScript
How to Get Jquery to Select Elements with a . (Period) in Their Id
What's the Fastest Way to Loop Through an Array in JavaScript
Expression Inside Switch Case Statement
How to Access an SQLite Database from JavaScript
How to Access the Contents of an Svg File in an <Img> Element