Hi Web Developers! back again with the tech teacher. this time the tech teacher will share a tutorial on how to make a website or blog not CTRL+U and right-click. For masters, masters, and the like, please correct me if something isn't quite right, but I don't think there is and for those of you who are looking at this article, please follow it and try it on your respective computers. Ok, continue to the tutorial.
Surely all of you don't want anyone to see your website code, or someone trying to copy your article? Now, in the way that we will discuss this time, the code for our website or blog cannot be seen by Ctrl +U or copied by Right click. Here we will take advantage of a redirect or redirect using the JavaScript function, when our website or blog is ctrl+u and right -click it will to a certain page that we have specified.
To do so, please look at the code below:
First
<script type='text/javascript'>
function redirect1(e){if(e.ctrlKey&&85==e.which)return window.location.replace("https://Fill in your page URL"),!1}
function redirect2(e){if(3==e.which)return window.location.replace("https://Fill in your page URL"),!1}
document.onkeydown=redirect1,
document.oncontextmenu=redirect2;
</script>
Please fill in the redirect URL with the URL you want.
for example, I redirected to the URL https://habibkhan-tech.blogspot.com/
So it's written like this:
<script type='text/javascript'>
function redirect1(e){if(e.ctrlKey&&85==e.which)return window.location.replace("https://https://habibkhan-tech.blogspot.com/"),!1}
function redirect2(e){if(3==e.which)return window.location.replace("https://https://habibkhan-tech.blogspot.com/"),!1}
document.onkeydown=redirect1,
document.oncontextmenu=redirect2;
</script>
if something is unclear please write in the comment section.
Try these codes in your editor to see the result by yourself.
Hope it'll be useful, thank you.