简体   繁体   中英

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. 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

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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