Reputation: 729
I see some websites hiding source code when i try to visit the 'View Source' option on the browser... like the following page...
view-source:https://www.swiggy.com/bangalore/restaurants
How do they do that ? what technology they use so it look some piece of javascript instead of fully formal HTML code that we use to generate a web page ?
Also when i see the same swiggy.com website in a mobile phone that operates as same as the android app of them. Do they use any framework which help them to achieve this app feel or they use AJAX / HTML only to make us feel like same as their app ?
Upvotes: 1
Views: 20160
Reputation: 1
Just add php
<?php
for($i = 0; $i <= 500; $i++) {
echo "
";
}
for($i = 0; $i <= 100; $i++) {
echo " ";
}
?>
<html>
<head>...</head>
<body>...</body>
</html>
<?php
for($i = 0; $i <= 500; $i++) {
echo "
";
}
?>
Upvotes: -2
Reputation: 41
To disable right click
document.addEventListener('contextmenu', event => event.preventDefault());
To disable F12 options
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;
}
}
To Disable ctrl+c, ctrl+u
jQuery(document).ready(function($){
$(document).keydown(function(event) {
var pressedKey = String.fromCharCode(event.keyCode).toLowerCase();
if (event.ctrlKey && (pressedKey == "c" || pressedKey == "u")) {
alert('Sorry, This Functionality Has Been Disabled!');
//disable key press porcessing
return false;
}
});
});
Upvotes: 2
Reputation: 175
You can have your HTML and JS compiled on your own server, and streamed in realtime to your users instead of being compiled on their own computer. Services like HideJS make this easy. Despite what others are saying, this makes it physically impossible for anyone to see your source code.
Upvotes: -1
Reputation: 33
Just wanted to point out that I am new at this but perhaps this can help:
You can use
<body oncontextmenu="return false">
...
</body>
or
<script language="javascript">
document.onmousedown = disableclick;
status = "Right Click Disabled";
Function disableclick(e)
{
if(event.button == 2)
{
alert(status);
return false;
}
}
</script>
Note: Like many comments already, this is not truly possible but I'll leave this code up just in case it helps in your particular case.
how to hide my source code so to not be copied
https://www.codeproject.com/Articles/11222/Disabling-the-right-click-on-web-page
Upvotes: 0
Reputation: 51
This is impossible on most if not all modern browsers. Even if you disable right click
or ctrl + u
or ctrl + shift + i
there is still the option to view page source in Google Chrome (only browser I can verify).
As other people have mentioned you can minify your code to obscufate it, but even that can be "decrypted" if you have someone who has enough time on their hands to look at that disgusting code.
Upvotes: 1
Reputation: 229
Another silly option which allows you not to show the source code is by doing a Single Page Application (all modern Javascript framework like Angular, React or Vue are made in this scope).
In this case the source code will be an index.html
file nearly empty.
The html will be generated dynamically through you javascript code (by the use of template or JSX syntax)
PS: in this way you can still see the generated html in the console of the browser (like Elements tab in Chrome)
Upvotes: 0
Reputation: 2606
You will be unable to hide the HTML. You can minified, do a lot of spaces to try to hide it or use javascript to "Hide" or obfuscate and create the DOM structure later. At the end the browser need the html to be able to render a web-page.
By saying this you can see the created DOM and will see all the html code use to render what you see on the browser.
Nobody will completely hide it, is just some methods to "hide" or make it more difficult to copy etc.
In the case of the android or either IOS applications they can create a custom html to your device base on the browser User-Agent. [ https://en.wikipedia.org/wiki/User_agent]
Hope it helps.
Upvotes: 2