简体   繁体   English

JavaScript中的验证码在视图源代码中显示代码

[英]Captcha in JavaScript displaying the code in view source code

I have created a JSP page with captcha in JavaScript, but the problem is the script is viewable when I click "View source code" option by right clicking the JSP page. 我已经在JavaScript中用验证码创建了一个JSP页面,但是问题是,当我通过右键单击JSP页面单击“查看源代码”选项时,该脚本是可见的。 Even if I block the right click option, the code can be still viewable through "View source code" in Edit menu. 即使我阻止了右键单击选项,仍可以通过“编辑”菜单中的“查看源代码”来查看代码。

Any idea on how I can solve this problem? 关于如何解决此问题的任何想法吗? I am very new to JSP and servlets... Thanks 我对JSP和servlet非常陌生...谢谢

JavaScript is executed on the client side, so it will have to be downloaded in the user's browser, there's no way to prevent that. JavaScript是在客户端执行的,因此必须在用户浏览器中下载JavaScript,无法防止这种情况的发生。

You can however have a look at minification and/or obfuscation , but that will not prevent the user to see your script, it will just make it harder to read and understand. 但是,您可以查看最小化和/或混淆 ,但这不会阻止用户查看您的脚本,只会使阅读和理解变得更加困难。

As for Captchas, that's typically the kind of thing you want to handle server-side (in a servlet, for example), and not client-side (in JavaScript code). 对于Captchas,通常这是您要处理服务器端(例如,在servlet中)而不是客户端(在JavaScript代码中)的事情。

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

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