is there a javascript method to check if a user changes a given code?
Example:
<div id="mycodestyle">
<a href="http://www.example.com"><img src="image.gif"></a>
</div>
if the user now changes the code like
<div id="mycodestyle">
<img src="image.gif">
</div>
he get’s a message -> Code modified. Extremetracking uses the same method, but I don´t know how they do it.
Here is the code of extremetracking
<div id="eXTReMe">
<a href="http://extremetracking.com/open?login=example">
<img src="http://t1.extreme-dm.com/i.gif" style="border: 0;"
height="38" width="41" id="EXim" alt="eXTReMe Tracker" /></a>
<script type="text/javascript"><!--
EXref="";
top.document.referrer?EXref=top.document.referrer:EXref=document.referrer;
//--></script>
<script type="text/javascript"><!--
var EXlogin='example' // Login
var EXvsrv='s10' // VServer
EXs=screen;
EXw=EXs.width;
navigator.appName!="Netscape"?EXb=EXs.colorDepth:EXb=EXs.pixelDepth;
EXsrc="src";
navigator.javaEnabled()==1?EXjv="y":EXjv="n";
EXd=document;
EXw?"":EXw="na";
EXb?"":EXb="na";
EXref?EXref=EXref:EXref=EXd.referrer;
EXd.write("<img "+EXsrc+"=http://e1.extreme-dm.com",
"/"+EXvsrv+".g?login="+EXlogin+"&",
"jv="+EXjv+"&j=y&srw="+EXw+"&srb="+EXb+"&",
"l="+escape(EXref)+" height=1 width=1>");
//--></script>
<noscript><div id="neXTReMe"><img height="1" width="1" alt=""
src="http://e1.extreme-dm.com/s10.g?login=example&j=n&jv=n" />
</div></noscript>
</div>
Short answer: Yes, absolutely possible.
It is of course possible to watch your
DOMandHTML Markupwith Javascript. You could just have some sort of interval which checks for certain things or even use theDOM Level 3 Mutation EventslikeDOMNodeRemovedorDOMSubtreeModified.The real question is, is it worth anything ? NO!
Any Clientside code could get modified or just removed the same way someone modifies your HTML markup. There is zero chance to have that kind of security on the client side only.
You would have to send your complete HTML code (or probably only parts of it) back to your server for any kind of validation.