我正在查看我们网站上的一些代码,直到我来到这个
<script>
(function (a) {
_q = function () { return a; };
$ = function (f) { typeof f === 'function' && a.push(arguments); return $; };
jQuery = $.ready = $;
}([]));
</script>
然后是一堆插件,包括 jQuery。
我只是不明白这意味着什么,我想知道它是如何工作的,以便能够操纵代码。谁能逐行解释代码?
编辑
很抱歉代码不好。我也在徘徊它的用途,这就是我在这里问它的原因。无论如何,这是 head 标签内的全部代码。
<head>
<meta charset="utf-8">
@foreach (string domain in
ViewBag.Prefetches is string[] ? ViewBag.Prefetches : new string[] { })
{
@Html.Prefetch(domain)
}
<title>
@{@ViewBag.SiteName
if (ViewBag.Title != null)
{ @ViewBag.SiteDelimiter @ViewBag.Title }
}
</title>
<meta name="description" content="">
<meta name="author" content="">
<meta http-equiv="imagetoolbar" content="false">
<link href="@Url.ContentArea("~/css/global/normalize.css")" rel="stylesheet" />
@foreach (string stylesheet in
ViewBag.Stylesheets is string[] ? ViewBag.Stylesheets : new string[] { @"style.css" })
{
<link href="@Url.ContentArea("~/css/" + stylesheet)" rel="stylesheet" />
}
@RenderSection("CustomCss", required: false)
<link href="@Url.ContentArea("~/css/global/helpers.css")" rel="stylesheet" />
<link href="@Url.ContentArea("~/css/global/media.css")" rel="stylesheet" />
<script src="@Url.ContentArea("~/js/global/modernizr-2.5.3.min.js")"></script>
<script>
(function (a) {
_q = function () { return a; };
$ = function (f) { typeof f === 'function' && a.push(arguments); return $; };
jQuery = $.ready = $;
}([]));
</script>
@RenderSection("OverrideJs", required: false)
</head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="@Url.ContentArea("~/js/global/jquery-1.7.2.min.js")"><\/script>');</script>
@foreach (string script in
ViewBag.Scripts is string[] ? ViewBag.Scripts : new string[] { })
{
<script src="@script"></script>
}
<script>
Modernizr.load({
test: window.JSON,
nope: '@Url.Content("~/Scripts/Polyfills/json.polyfill.js")'
});
(function (i, s, q, l) {
for (q = window._q(), l = q.length; i < l;) {
$.apply(this, s.call(q[i++]));
}
}(0, Array.prototype.slice));
</script>
<!--[if lt IE 7 ]>
<script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
<script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
<![endif]-->
我无法提供链接,因为这些代码用于您必须登录的特定页面。
无论如何感谢您的帮助。