Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/72.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
Javascript 仅在某些aspx页面上动态加载jquery库_Javascript_Jquery_Html_Asp.net_Jquery Ui - Fatal编程技术网

Javascript 仅在某些aspx页面上动态加载jquery库

Javascript 仅在某些aspx页面上动态加载jquery库,javascript,jquery,html,asp.net,jquery-ui,Javascript,Jquery,Html,Asp.net,Jquery Ui,由于特定的原因。我在表单标记中有jquery引用,表单标记位于body html标记中,而不是head html标记中 在这里之前,一切都很好,但是由于我使用代码的方式,jquery库在每个 第页(aspx页) 我只想在需要jquery引用的页面上加载它们。有什么办法我能做到吗 以下是我当前的母版页代码: <body> <form id="form2" runat="server"> <asp:ScriptManager ID="ScriptMana

由于特定的原因。我在表单标记中有jquery引用,表单标记位于body html标记中,而不是head html标记中

在这里之前,一切都很好,但是由于我使用代码的方式,jquery库在每个 第页(aspx页)

我只想在需要jquery引用的页面上加载它们。有什么办法我能做到吗

以下是我当前的母版页代码:

<body>
    <form id="form2" runat="server">
    <asp:ScriptManager ID="ScriptManagerService" runat="server">
        <Scripts>
            <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ScriptMode="Auto" />
            <asp:ScriptReference Path="http://code.jquery.com/jquery-migrate-1.2.1.js" ScriptMode="Auto" />
            <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" ScriptMode="Auto" />
        </Scripts>
    </asp:ScriptManager>
   </form>
</body>

在母版页中删除对jQuery的scriptreference,并将带有对jQuery引用的ScriptManagerProxy添加到需要它们的页面:



如果只有特定的页面需要jQuery,这意味着您正在这些页面上添加自定义客户端代码。在这种情况下,只需在自定义代码中加载jQuery引用,例如使用脚本标记。
<body>
    <form id="form2" runat="server">
        <asp:ScriptManagerProxy ID="ScriptManagerService" runat="server">
            <Scripts>
                <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" ScriptMode="Auto" />
                <asp:ScriptReference Path="http://code.jquery.com/jquery-migrate-1.2.1.js" ScriptMode="Auto" />
                <asp:ScriptReference Path="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js" ScriptMode="Auto" />
            </Scripts>
        </asp:ScriptManagerProxy>
    </form>
</body>