How to prevent html/JavaScript code modification

前端 未结 8 1844
一向
一向 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:38

    The only way to do it (in my opinion) is not have the page content load until the user does your desired action. After he answers the question (or whatever) you send an AJAX request for the content (of course, as thejh said, you should also validate the answer on the server, preferably in the same request). So you load page header, banners and anything not critical, but the actual content (say an article on a blog) should not be loaded until the user does your action.

    Everything that a user's browser receives belongs to the user, so you can't enforce anything on that.

提交回复
热议问题