0

Is there a way for prevent any user from editing my html code from UI using inspect element ? I have done research there's many why to prevent inspect element ( or Right-Click ) but seems not all of them are effective .

So my question is how to prevent the user from editing my HTML Code using inspect element and what's more suggestion I can add to enhance website security?

Duaa
  • 77
  • 3
  • 10
  • Do you have a specific example where you'd need security on the front-end? – ShamPooSham Jan 19 '20 at 19:02
  • @ShamPooSham i'm taking about in general what can be enhanced in security side for my HTML code – Duaa Jan 19 '20 at 19:04
  • It's HTML. Why does it need security? – Quentin Jan 19 '20 at 19:05
  • @Duaa I have a hard time seeing where this would be useful, that's why I'm asking for a concrete example. If you don't want a user to see a specific element for example, you need to block it on the back-end instead of hiding it in the HTML. But maybe there's another case than hiding elements that you're thinking about – ShamPooSham Jan 19 '20 at 19:07

2 Answers2

1

You are going off on a tangent. No there is no way to prevent a user from editing content they have downloaded to their computer. But they are not editing your website - the website security is not being compromised.

symcbean
  • 47,736
  • 6
  • 59
  • 94
1

There is no way to completely block inspect element.

You can try to prevent amateur users from doing it by blocking the context menu that shows up on right click.

document.addEventListener('contextmenu', function(e) {
  e.preventDefault();
});

Users will not be able to access this:

enter image description here

It is completely normal to view a website's frontend HTML code.

As long as you use good backend practices, there will be no security issues.

aiyan
  • 406
  • 4
  • 11