Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置jQuery插件_Jquery_Asp.net Mvc - Fatal编程技术网

设置jQuery插件

设置jQuery插件,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我正在审查我们网站上的一些代码,直到我来到这个网站 <script> (function (a) { _q = function () { return a; }; $ = function (f) { typeof f === 'function' && a.push(arguments); return $; }; jQuery = $.ready = $; }([])); </script&g

我正在审查我们网站上的一些代码,直到我来到这个网站

<script>
    (function (a) {
        _q = function () { return a; };
        $ = function (f) { typeof f === 'function' && a.push(arguments); return $; };
        jQuery = $.ready = $;
    }([]));
</script>  

(职能(a){
_q=函数(){returna;};
$=函数(f){typeof f=='function'和&a.push(参数);返回$;};
jQuery=$.ready=$;
}([]));
然后是一堆插件,包括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]-->

@foreach(中的字符串域)
ViewBag.Prefetches是字符串[]?ViewBag.Prefetches:新字符串[]{})
{
@Html.Prefetch(域)
}
@{@ViewBag.SiteName
如果(ViewBag.Title!=null)
{@ViewBag.SiteDelimiter@ViewBag.Title}
}
@foreach(中的字符串样式表)
ViewBag.Stylesheets是字符串[]?ViewBag.Stylesheets:新字符串[]{@“style.css”})
{ 
}
@RenderSection(“CustomCss”,必填项:false)
(职能(a){
_q=函数(){returna;};
$=函数(f){typeof f=='function'和&a.push(参数);返回$;};
jQuery=$.ready=$;
}([]));
@RenderSection(“OverrideJs”,必需:false)
window.jQuery | | document.write(“”);
@foreach(中的字符串脚本)
脚本是字符串[]?ViewBag.Scripts:新字符串[]{})
{ 
}
现代化负荷({
测试:window.JSON,
否:'@Url.Content(“~/Scripts/Polyfills/json.polyfill.js”)'
});
(功能(i、s、q、l){
对于(q=window.\u q(),l=q.length;i
我无法提供链接,因为这些代码用于您必须登录的特定页面。

无论如何,谢谢你的帮助。

简短回答:如果jQuery已经加载,它会记录日志

长答案:看起来它所做的只是在加载变量“jQuery”后添加一个返回参数数组的函数(这是一个类似数组的变量,存在于所有函数的执行上下文中,感谢Fabricio Matté)。据我所知,由于没有参数被发送到函数中,它所要做的就是记录调用它的范围

看起来“jQuery”变量被访问得更深一点,如果不设置,它将加载jQuery。但我认为它无论如何都无法访问,因为我在任何地方都看不到全局声明的变量


它的用途是首先尝试从Google的主机加载jQuery。如果失败,则在本地加载jQuery

如果不看整件事,就有点难以猜测这到底在做什么。你能提供一个url吗?我不能提供链接,因为代码是在你必须登录的特定页面中使用的。
arguments
是一个类似数组的变量,存在于所有函数的执行上下文中。