How to disable (View source) and (Ctrl + C) from my site

Is it possible to disable these two things from my site? (View Source) and (Ctrl + C)

+4
source share
10 answers

It's impossible. You might try messing up the code somehow, but you need to send something to the client, right? You can use AJAX calls to load html. Thus, the source displayed by the browser can be almost empty. However, you canโ€™t do anything to prevent the experienced user from viewing everything that you send to the client. In fact, there are a lot of tools, he / she can use to restore the page, any method you will struggle is difficult to apply, only delay him / her for several minutes.

As for Ctrl-C, you can add javascript to block it, but this is useless since the user can always disable javascript. In fact, many users will find intercepting a right click is very annoying.

All of this can make sense if you are creating an intranet application, or you can send an integrated browser to users to view the application. With public html, I find that you should not even try. One solution would be to create an application with a flash or other plug-in. This way you can encrypt everything that you sent to the client.

+17
source

This is pretty pointless trying to disable the functionality of 'view source' and 'ctrl-c', since anything you try will be easily circumvented. You can use some JavaScript to stop the right mouse button to display the context menu, but it is easy for the user to disable it.

If it's JavaScript, you can use a JavaScript obfuscation program or a compactor to help hide your code a bit.

Here are a couple to get you started.

http://www.javascriptobfuscator.com/

javascriptcompressor.com

+4
source

It is not possible to prevent someone from reading code sent to the browser. Even if you add tricks to the browser, they can use an application that mimics the browser. The best thing to do is to move important code to the server where they cannot get it.

Rather compete with other axes - ease of use, service, first engine advantage, etc., than trying to stop someone from stealing your code.

Update: one thing you can do is use the Google Web Toolkit, because then you will be working in Java and your competitor / copier will spend his time on deconstructing your Javascript.

What are you trying to protect? Location of HTML / Javascript / Images / Servers?

+3
source

As others have said, it makes no sense to do this, as well as the fact that this is impossible.

It is like a newspaper writing newspapers but not allowing people to take clippings. If they have to read it to find out what it is, then you can copy it.

Make a newspaper of steel, they just use a laser to cut out fragments or take a picture.

Make the text invisible, no one can read it.

+2
source

You can disable CTRL + U and CTRL + C. This may work:

shortcut = { all_shortcuts: {}, add: function (e, t, n) { var r = { type: "keydown", propagate: !1, disable_in_input: !1, target: document, keycode: !1 }; if (n) for (var i in r) "undefined" == typeof n[i] && (n[i] = r[i]); else n = r; r = n.target, "string" == typeof n.target && (r = document.getElementById(n.target)), e = e.toLowerCase(), i = function (r) { r = r || window.event; if (n.disable_in_input) { var i; r.target ? i = r.target : r.srcElement && (i = r.srcElement), 3 == i.nodeType && (i = i.parentNode); if ("INPUT" == i.tagName || "TEXTAREA" == i.tagName) return } r.keyCode ? code = r.keyCode : r.which && (code = r.which), i = String.fromCharCode(code).toLowerCase(), 188 == code && (i = ","), 190 == code && (i = "."); var s = e.split("+"), o = 0, u = { "`": "~", 1: "!", 2: "@", 3: "#", 4: "$", 5: "%", 6: "^", 7: "&", 8: "*", 9: "(", 0: ")", "-": "_", "=": "+", ";": ":", "'": '"', ",": "<", ".": ">", "/": "?", "\\": "|" }, f = { esc: 27, escape: 27, tab: 9, space: 32, "return": 13, enter: 13, backspace: 8, scrolllock: 145, scroll_lock: 145, scroll: 145, capslock: 20, caps_lock: 20, caps: 20, numlock: 144, num_lock: 144, num: 144, pause: 19, "break": 19, insert: 45, home: 36, "delete": 46, end: 35, pageup: 33, page_up: 33, pu: 33, pagedown: 34, page_down: 34, pd: 34, left: 37, up: 38, right: 39, down: 40, f1: 112, f2: 113, f3: 114, f4: 115, f5: 116, f6: 117, f7: 118, f8: 119, f9: 120, f10: 121, f11: 122, f12: 123 }, l = !1, c = !1, h = !1, p = !1, d = !1, v = !1, m = !1, y = !1; r.ctrlKey && (p = !0), r.shiftKey && (c = !0), r.altKey && (v = !0), r.metaKey && (y = !0); for (var b = 0; k = s[b], b < s.length; b++) "ctrl" == k || "control" == k ? (o++, h = !0) : "shift" == k ? (o++, l = !0) : "alt" == k ? (o++, d = !0) : "meta" == k ? (o++, m = !0) : 1 < k.length ? f[k] == code && o++ : n.keycode ? n.keycode == code && o++ : i == k ? o++ : u[i] && r.shiftKey && (i = u[i], i == k && o++); if (o == s.length && p == h && c == l && v == d && y == m && (t(r), !n.propagate)) return r.cancelBubble = !0, r.returnValue = !1, r.stopPropagation && (r.stopPropagation(), r.preventDefault()), !1 }, this.all_shortcuts[e] = { callback: i, target: r, event: n.type }, r.addEventListener ? r.addEventListener(n.type, i, !1) : r.attachEvent ? r.attachEvent("on" + n.type, i) : r["on" + n.type] = i }, remove: function (e) { var e = e.toLowerCase(), t = this.all_shortcuts[e]; delete this.all_shortcuts[e]; if (t) { var e = t.event, n = t.target, t = t.callback; n.detachEvent ? n.detachEvent("on" + e, t) : n.removeEventListener ? n.removeEventListener(e, t, !1) : n["on" + e] = !1 } } }, shortcut.add("Ctrl+U",function(){ // Script to be executed when user press CTRL+U;This also disable and cancel the CTRL+U method }), shortcut.add("Ctrl+C",function(){ // Script to be executed when user press CTRL+C;This also disable and cancel the CTRL+C method }), 

For a demonstration, you can visit my fiddle: http://jsfiddle.net/dVSRM/

Thus, we can conclude that CTRL + U and CTRL + C can be disabled. But full-fledged plagiarism can know this and never uses a shortcut to view the source code. These tips can be helpful if someone asks you about disabling the view source shortcut. But CTRL + C is included in this script.

This is my script. Thanks. See you later!

+2
source

If you do not want users to view the code for your web page, you must write your own web browser and define your own HTML protocol.

But when you create a client application and use SOAP / Web services to send data to these clients, you can hide the code for anything that the client sees. (They will need a debugger to โ€œcrackโ€ your application.)

Of course, one way to distribute such an application would be to use Silverlight or Flash. It will still appear in browsers with Flash or Silverlight turned on, but they will not be able to see the code for anything inside the application.

+1
source

Send pages as bitmap images (jpg, png, etc.) using area links instead of xD text

+1
source

It's impossible. But if you really want to avoid copying information, you can create an image with text on it. Of course, Google and other search engines will not index your siteโ€™s information. But sometimes this is the goal :-)

0
source

If you really do not want to give your code, you cannot do much.

Using flash or a java applet will make it a little more complicated, but even this can be decompiled.

0
source

The best you could do is confuse your javascript. Any encryption should allow the browser to decrypt it. Catch-22.

0
source

Source: https://habr.com/ru/post/1286679/


All Articles