{"id":461,"date":"2018-04-15T19:59:39","date_gmt":"2018-04-15T14:29:39","guid":{"rendered":"http:\/\/blog.openwebsolutions.in\/?p=461"},"modified":"2018-04-15T20:27:51","modified_gmt":"2018-04-15T14:57:51","slug":"prevent-debugging-website-using-javascript","status":"publish","type":"post","link":"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/","title":{"rendered":"Prevent debugging of a Website using Javascript"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>In this blog I am going to show you how to prevent debugging of your website by using Javascript. For this simple trick you need to know basic HTML and Javascript language.<\/p>\n<p>First of all we have to write a code\u00a0that disables all the ways to access Inspect Element as well as to view the source code and to prevent Cut, Copy and Paste in JavaScript.\u00a0We will prevent the following.<\/p>\n<ul>\n<li>\n<pre>Right Click<\/pre>\n<\/li>\n<li>\n<pre>Ctrl + Shift + I<\/pre>\n<\/li>\n<li>\n<pre>Ctrl + Shift + J<\/pre>\n<\/li>\n<li>\n<pre>Ctrl + Shift + C<\/pre>\n<\/li>\n<li>\n<pre>Ctrl + U<\/pre>\n<\/li>\n<li>\n<pre>F12<\/pre>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3>Disable Right Click<\/h3>\n<p>&nbsp;<\/p>\n<pre>\/\/this will also disable full page\r\n\r\n$(\"body\").on(\"contextmenu\",function(e){\r\n return false;\r\n});<\/pre>\n<p>&nbsp;<\/p>\n<h3>Disable Cut, Copy, Paste<\/h3>\n<p>&nbsp;<\/p>\n<pre>$('body').bind('cut copy paste', function (e) {\r\n\u00a0 \u00a0 e.preventDefault();\r\n});<\/pre>\n<p>&nbsp;<\/p>\n<h3>Prevent Debugging the Website<\/h3>\n<p>&nbsp;<\/p>\n<pre class=\"prettyprint linenums\">document.onkeydown = function(e) {\r\n    \r\n    \/\/prevent key F12\r\n    if(event.keyCode == 123) {\r\n        return false;\r\n    }\r\n\r\n    \/\/prevent CTRL + Shift + I\r\n    if(e.ctrlKey &amp;&amp; e.shiftKey &amp;&amp; e.keyCode == 'I'.charCodeAt(0)){\r\n        return false;\r\n    }\r\n\r\n    \/\/prevent CTRL + Shift + J\r\n    if(e.ctrlKey &amp;&amp; e.shiftKey &amp;&amp; e.keyCode == 'J'.charCodeAt(0)){\r\n        return false;\r\n    }<\/pre>\n<pre class=\"prettyprint linenums\">    \/\/prevent CTRL + Shift + C\r\n    if(e.ctrlKey &amp;&amp; e.shiftKey &amp;&amp; e.keyCode == 'C'.charCodeAt(0)){\r\n        return false;\r\n    }<\/pre>\n<pre class=\"prettyprint linenums\">    \/\/prevent CTRL + U \r\n    if(e.ctrlKey &amp;&amp; e.keyCode == 'U'.charCodeAt(0)){ \r\n        return false; \r\n    } \r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>That&#8217;s it. You will now have a website with Debug prevent. Keep coding!<\/p>\n<p><strong><em>Please share if you like it!<\/em><\/strong><\/p>\n<pre><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; In this blog I am going to show you how to prevent debugging of your website by using Javascript. For this simple trick you need to know basic HTML and Javascript language. First of all we have to write a code\u00a0that disables all the ways to access Inspect Element as well as to view [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":462,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Prevent debugging of a Website using Javascript - Openweb Solutions Blog<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Prevent debugging of a Website using Javascript - Openweb Solutions Blog\" \/>\n<meta property=\"og:description\" content=\"&nbsp; In this blog I am going to show you how to prevent debugging of your website by using Javascript. For this simple trick you need to know basic HTML and Javascript language. First of all we have to write a code\u00a0that disables all the ways to access Inspect Element as well as to view [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Openweb Solutions Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-15T14:29:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-15T14:57:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2018\/04\/banner-prevent-inspect.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"497\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/\",\"name\":\"Openweb Solutions Blog\",\"description\":\"Transforming ideas into reality\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/openwebsolutions.in\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/wp-content\/uploads\/2018\/04\/banner-prevent-inspect.jpg\",\"width\":1024,\"height\":497,\"caption\":\"Prevent Debug\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/#webpage\",\"url\":\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/\",\"name\":\"Prevent debugging of a Website using Javascript - Openweb Solutions Blog\",\"isPartOf\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/#primaryimage\"},\"datePublished\":\"2018-04-15T14:29:39+00:00\",\"dateModified\":\"2018-04-15T14:57:51+00:00\",\"author\":{\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/openwebsolutions.in\/blog\/prevent-debugging-website-using-javascript\/\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#\/schema\/person\/615090f954d8460cf6186cf920b47398\",\"name\":\"Preetam Mallick\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/openwebsolutions.in\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ed836329485e177373e4ff5323b6670a?s=96&r=g\",\"caption\":\"Preetam Mallick\"},\"description\":\"Frontend developer at Openweb Solutions\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/461"}],"collection":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/comments?post=461"}],"version-history":[{"count":3,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions"}],"predecessor-version":[{"id":466,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/posts\/461\/revisions\/466"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media\/462"}],"wp:attachment":[{"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/media?parent=461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/categories?post=461"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/openwebsolutions.in\/blog\/wp-json\/wp\/v2\/tags?post=461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}