How to prevent html/JavaScript code modification
Solution 1:
It is not possible (which is a very good thing).
Solution 2:
To defeat the method described in the question:
- You can use the keyboard shortcuts to the console/tools (Ctrl+Shift+I in Chrome)
- You can use the resource/net panel to see the source
- You can see it at any other level, e.g. Fiddler
- You can use a bookmarklet for easier access
No, you can't prevent people seeing or modifying your source/script if they want to...the ones you most want to prevent are the most able to circumvent any deterrent (and that's all anything you do is, a deterrent, not a stop) you put in place.