How to prevent html/JavaScript code modification

前端 未结 8 1739
一向
一向 2020-11-30 13:17

I would like to know if there is a way to prevent an html page with jQuery or javascript to be modified by the user to change its behavior.

A user can modify it usin

相关标签:
8条回答
  • 2020-11-30 13:41

    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.

    0 讨论(0)
  • 2020-11-30 13:45

    For sure you can't prevent anybody from doing what he wants to, but you can make changes more difficult.

    Take a look at the DOMEvents, especially the Mutation-Events. Those give you the ability to see when something has changes(attributes, removed/inserted nodes, data in textnodes ...). For example you could build a function that watches some special attributes you would'nt have to get changed and reload the page, if this happens.

    0 讨论(0)
提交回复
热议问题