如何隐藏< scripts>和< link>使用angularjs在HTML页面中的标签? [英] How to hide the <scripts> and <link> tags in HTML page using angularjs?
本文介绍了如何隐藏< scripts>和< link>使用angularjs在HTML页面中的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用Angular和HTML。我想让我的页面更安全,所以我隐藏了页面的代码和内容,因为我使用Angular指令来隐藏代码并且它是有效的。在该页面< scripts>和标签是可用的,我需要也隐藏在页面是否有任何可能性。
我尝试过:
Javascript文件
I'm currently working in Angular and HTML. I want to make my page more secure so I hide the code and content of the page for that I used Angular directive to hide the code and it's works. In that page <scripts> and tags are available I need that also hide from the page is there any possibilities for that.
What I have tried:
Javascript files
<script src="/Scripts/Angular.js"></script>
<script src="/Scripts/jquery-1.9.1.js"></script>
<script src="/Scripts/bootstrap.min.js"></script>
CSS文件
CSS files
<link href="Content/Styles.css" rel="stylesheet" />
<link href="Content/bootstrap.css" rel="stylesheet" />
推荐答案
您可以不可能隐藏用户的脚本和样式。原因很简单:要正确呈现页面,浏览器需要访问这些文件。如果您的浏览器可以访问它们,用户也可以访问它们。
You can impossibly hide scripts and styles from a user. The reason is simple: to render your page correctly, your browser needs to access these files. If your browser can access them, a user can do it too.
是的,这是可能的。试试这个。
Script.js
Yes, It's possible. Try this.
Script.js
function loadJSAtOnload() {
var scripts = [
"/Scripts/Angular.js",
"/Scripts/jquery-1.9.1.js",
"/Scripts/bootstrap.min.js",
];
for (var i = 0; i < scripts.length; i++) {
console.log('Loading script ' + scripts[i]);
var scriptType = document.createElement('script');
scriptType.type = 'text/javascript';
scriptType.src = scripts[i];
document.body.appendChild(scriptType);
}
};
if (window.addEventListener)
addEventListener('load', loadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent('onload', loadJSAtOnload);
else window.onload = loadJSAtOnload;
Style.css
Style.css
@import url('Content/Styles.css');
@import url('Content/bootstrap.css');
调用主页中的文件。
Call the files in Main Page.
<script src="scripts.js"></script>
<link href="Style.css" rel="stylesheet" />
这篇关于如何隐藏< scripts>和< link>使用angularjs在HTML页面中的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文