0

is there any way to protect html element properties like style, html content and so on with javasacript, jquery or similar? For example if I have a div:

<div id="myDiv"  style="font-weight: bold;"> Hello Stackoverflow </div>

is there any way to prevent any kind of script to modify the html ("Hello Stackoverflow") or the style of this div?

Thanks

Fseee
  • 2,476
  • 9
  • 40
  • 63

3 Answers3

1

Probably the only way would be to set up a recurring function (using setInterval) that will check for changes in your elements.

As far as I know, there is no cross-browser event that gets fired when CSS property changes.

There are, however, some options for newer browsers: Event detect when css property changed using Jquery

Community
  • 1
  • 1
Zathrus Writer
  • 4,311
  • 5
  • 27
  • 50
1

The only way I can think of is to use Flash, Java, Silverlight or something similar on the client side.

You can not prevent a client from modifying anything on your page if it is html, css or javascript. Even if you do check inputs with javascript they can disable or remove the function that checks it. That is why you always need to validate all inputs on the server side when using data sent from a client.

Roy
  • 428
  • 1
  • 3
  • 9
-1

No, it isn't possible to do that.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335