隐藏html页面中的javascript/jquery脚本? [英] hide javascript/jquery scripts from html page?

查看:44
本文介绍了隐藏html页面中的javascript/jquery脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在html页面(右键单击查看源)中隐藏我的javascript/jquery脚本?请提出建议以实现这一目标.

How do I hide my javascript/jquery scripts from html page (from view source on right click)? please give suggestion to achive this .

谢谢.

推荐答案

您最好的选择是在加载dom树后立即删除脚本标签,或者在JavaScript中动态创建脚本标签.

Your best bet is to either immediately delete the script tags after the dom tree is loaded, or dynamically create the script tag in your javascript.

无论哪种方式,如果有人想使用Web开发人员工具或Firebug,他们仍然会看到javascript.如果在浏览器中,它将显示出来.

Either way, if someone wants to use the Web developer tool or Firebug they will still see the javascript. If it is in the browser it will be seen.

动态创建脚本标签的一个优点是,如果关闭了javascript,则不会加载javascript.

One advantage of dynamically creating the script tag you will not load the javascript if javascript is turned off.

如果我关闭了javascript,我仍然可以在html中看到所有内容,因为您将无法删除脚本标签.

If I turned off the javascript I could still see all in the html, as you won't have been able to delete the script tags.

更新:如果您输入<script src='...' />,则看不到javascript,但确实看到了javascript文件的url,因此只需将其粘贴到地址栏中,您D/L的JavaScript.如果您动态删除脚本标签,它仍将位于查看源文件"源中,而不是在firebug的html源文件中,并且如果您动态创建该标签,则Firebug可以在View Source中看到它,而在View Source中.

Update: If you put in <script src='...' /> then you won't see the javascript but you do see the javascript file url, so it is just a matter of pasting that into the address bar and you d/l the javascript. If you dynamically delete the script tags it will still be in the View Source source, but not in firebug's html source, and if you dynamically create the tag then firebug can see it but not in View Source.

不幸的是,正如我提到的,Firebug总是可以看到javascript,因此它并没有被隐藏在那里.

Unfortunately, as I mentioned Firebug can always see the javascript, so it isn't hidden from there.

我没有尝试过的唯一方法,所以我不知道会发生什么,如果您将javascript作为ajax调用d/l,然后在其上使用'exec'来运行它.我不知道那是否会出现在任何地方.

The only one I haven't tried, so I don't know what would happen is if you d/l the javascript as an ajax call and then 'exec' is used on that, to run it. I don't know if that would show up anywhere.

这篇关于隐藏html页面中的javascript/jquery脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆