简体   繁体   English

Javascript:在客户端检测对JS / DOM的更改

[英]Javascript: Detect Changes to JS/DOM on the client side

Is it possible to detect if someone has altered the DOM/JS code on your webpage in the browser? 是否可以在浏览器中检测是否有人更改了您网页上的DOM / JS代码?

I'm thinking in terms of an online game written in JS, all the game code would be downloaded to the user's machine, which they can then edit to their will by using common script debugging/inspector tools. 我在考虑用JS编写的在线游戏,所有游戏代码都将下载到用户的计算机上,然后他们可以使用通用的脚本调试/检查器工具对其进行编辑。 Are there any methods for detecting if the DOM/JS code has changed? 有什么方法可以检测DOM / JS代码是否已更改?

No, there is not. 不,那里没有。 Even if there was such an event, it could be deleted or modified, just like the DOM. 即使发生此类事件,也可以像DOM一样将其删除或修改。

If you want to create a game which is hacker-proof, you really need to validate all the user actions on the server side, not on the client side. 如果要创建一个防黑客的游戏,则确实需要在服务器端而非客户端上验证所有用户操作。 I had the same questions about security of HTML5 games . 对HTML5游戏的安全性也有同样的疑问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM