隐藏源CSS代码 [英] Hiding the source CSS code

查看:105
本文介绍了隐藏源CSS代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好最近我看过网站,在查看源代码时会隐藏其源代码css!
这究竟是怎么可能的..
我假设有些javascript可以做到这一点。
这是我在Google上找到的一段代码。

Hello recently i have seen sites ,that hides their source css when viewed their source! How is this exactly possible.. I assume some javascript may do the trick. this is a piece of code that i found on Google.

<script type="text/javascript" src="css.js"></script>

var cssFile = document.createElement('link');
cssFile.type = 'text/css';
cssFile.rel = 'stylesheet';
cssFile.href = '/test.css';
cssFile.media = 'screen';
cssFile.title = 'dynamicLoadedSheet';
document.getElementsByTagName("head")[0].appendChild(cssFile); 

这个代码是隐藏我的CSS还是会伪造用户css的来源..?

So is this code going to hide my css or will fake the users the origin of css..?

推荐答案


这段代码将隐藏我的css

So is this code going to hide my css


或者会伪造用户css的来源..?

or will fake the users the origin of css..?

它使用View Source会更难以发现...但我没有看到任何人使用它作为第一种检查页面如何工作多年的方法。 DOM检查器工具将显示生成的< link> 元素,并将显示应用于任何给定元素的样式以及它们出现的样式表文件的链接。网络监视软件(包括内置于Firebug,Chrome开发者工具等中的软件等)也将显示样式表的HTTP请求和响应。

It will make it very slightly harder to spot using View Source… but I haven't see anyone use that as the first approach to examine how a page works for years. DOM inspector tools will show the generated <link> element, and will show the styles applying to any given element along with a link to the stylesheet file they appear in. Network monitoring software (including that which is built into Firebug, Chrome Developer Tools, etc, etc) will show the HTTP requests and responses for the stylesheets too.

它会做什么,是延迟任何加载CSS直到JS运行。这就是全部。

What it will do, is delay any loading of the CSS until the JS has run. That is all.

这可能是因为某些CSS仅用于启用了JS的浏览器(CSS可能隐藏某些内容,然后只通过JS交互显示,所以作者希望它默认为可见,如果以后不能用JS透露。

This may be so that some CSS is only used in browsers which have JS enabled (the CSS might hide some content which is then only revealed via JS interactions, so the author wants it to default to being visible if it can't later be revealed with JS).

这可能是内容首先加载并获得样式之后(作为内容加载性能优先于内容样式的黑客攻击)。

This may be so that the content loads first and gets styled later (as a hack to give content loading performance priority over content styling).

这篇关于隐藏源CSS代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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