-2

By disable I mean: when user enters the website with console already on, or turns on the console on the website, redirect the user to another page (or just don't allow to keep the console on; though, I doubt that is possible).

Gajus
  • 69,002
  • 70
  • 275
  • 438

1 Answers1

7

Why do you think it's your decision if people may use their browser extensions or not? It's none of your business.

However, you can check if there is window.console. It might be set in some browsers even without a Firebug-like extension being active though.

ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • 1
    This is sort a security issue. (as awkard it may sound) – Gajus May 01 '11 at 19:50
  • 11
    If this is a security issue something is very wrong. People can **read** and **modify** your JavaScript no matter what you are doing. They can also send arbitrary requests without you ever knowing they were not sent by your unmodified scripts. If a website does odd things when opening the console it's actually very tempting to investigate further and try to do exactly those bad things you are apparently trying to prevent. – ThiefMaster May 01 '11 at 19:52
  • 4
    @Guy: seriously? The security issue is in the website, not the browser's console. I don't think you could possibly excuse potentially sensitive information being accessible from the console. I also don't believe it's less effort to make your site inconsolable, than to secure your site. – Lee Kowalkowski May 01 '11 at 21:37
  • Well, by security I mean "visitor being able to browse trough the loaded JS." Basically it is possible to see the JS only trough the console.log/Net. Therefore I am wondering if it is possible to hide it from there as well. And simply not allowing people to use the console, seems like a valid solution. – Gajus May 01 '11 at 21:47
  • 1
    But @Guy, what are you trying to hide? Literally *everything* you could conceivably think you are hiding by mucking with the console will *still* be visible to anyone who acts as @ThiefMaster describes. – Kirk Woll May 01 '11 at 22:49
  • Well, the idea is to hide the content from primitive users, so to say. – Gajus May 01 '11 at 22:49
  • 4
    But those cannot do you any harm anyway. And in this case you better simply *minify* your JS code. It even saves you bandwidth and while there are scripts to restore formatting, restoring the original variable/function names is an annoying work that needs to be done manually - and if the code is more than a few lines people need a really good reason to do so. – ThiefMaster May 02 '11 at 06:08