Jquery 在 Sharepoint 中不工作

发布于 2024-11-23 16:51:17 字数 6164 浏览 2 评论 0原文

我想做一个包含 Jquery 效果(如切换)的 Web 部件。

需要此功能

当我们单击该工具、资源旁边的图像时,我们需要显示一个菜单...为此我会喜欢使用 jquery 切换,

添加了以下链接

<SharePoint:ScriptLink language="javascript" name="/_layouts/NMFSHeaderLinks/jquery-1.4.1-vsdoc.js"  Defer="true" runat="server"/>

我在 sharepoint 母版页和可视化 Web 部件中

<style type="text/css">
    a:hover
    {
        text-decoration:none;
        font-weight:bold;
    }
    .style1
    {
        width: 8px;
        height: 7px;
    }
</style>

<script type="text/javascript" src="../../../_layouts/NMFSHeaderLinks/jquery-1.4.1-vsdoc.js">


    $(document).ready(function () {
        $('#hpTools').click(function () {
            alert('Entered in jquery');
            $("#divtools").toggle("slow");
        });
    });


</script>

<table id="td">
<tr>
<td>
<asp:HyperLink ID="hpBlueBook" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" NavigateUrl="http://Sparsh" >Blue Book</asp:HyperLink>
&nbsp; |&nbsp;
</td>
<td><asp:HyperLink ID="hpReports" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" NavigateUrl="http://Sparsh">Reports</asp:HyperLink>

&nbsp;|</td>
<td>
<asp:HyperLink ID="hpTools" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Tools</asp:HyperLink>
&nbsp;<img alt="getTools" class="style1" id="tools"
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" />&nbsp;|&nbsp;


</td>
<td>
<asp:HyperLink ID="hpResources" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Resources</asp:HyperLink>

&nbsp;<img alt="GetResources" class="style1" 
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" />&nbsp;|
</td>
<td>
<asp:HyperLink ID="hpQuickLinks" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Quick Links</asp:HyperLink>

&nbsp;<img alt="GetQuick Links" class="style1" 
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td> <div id="divtools" style="display:none">
            <asp:Menu ID="ToolsMenu" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://www.google.com" Text="Google" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://www.yahoo.com" Text="Yahoo" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div></td>
        <td>
        <div id="Reports">
            <asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://www.google.com" Text="Static" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://www.yahoo.com" Text="Dynamic" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div>
        </td>
        <td>
        <div id="QuickLinks">
            <asp:Menu ID="Menu2" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://Sparsh" Text="Sparsh" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://webmail/owa" Text="Mail" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div>
        </td></tr>
</table>

,但它不会进入单击功能... 请让我知道我该如何继续......我也尝试了图像 ID,但不起作用

i Would like to do do one webpart which contains Jquery effects like toggle .

need this functionality

When we click on image beside that tools,resources we beed to display a menu...for that i would like to use jquery toggle

i have added the following link in sharepoint master page

<SharePoint:ScriptLink language="javascript" name="/_layouts/NMFSHeaderLinks/jquery-1.4.1-vsdoc.js"  Defer="true" runat="server"/>

and in the visual webpart

<style type="text/css">
    a:hover
    {
        text-decoration:none;
        font-weight:bold;
    }
    .style1
    {
        width: 8px;
        height: 7px;
    }
</style>

<script type="text/javascript" src="../../../_layouts/NMFSHeaderLinks/jquery-1.4.1-vsdoc.js">


    $(document).ready(function () {
        $('#hpTools').click(function () {
            alert('Entered in jquery');
            $("#divtools").toggle("slow");
        });
    });


</script>

<table id="td">
<tr>
<td>
<asp:HyperLink ID="hpBlueBook" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" NavigateUrl="http://Sparsh" >Blue Book</asp:HyperLink>
  | 
</td>
<td><asp:HyperLink ID="hpReports" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" NavigateUrl="http://Sparsh">Reports</asp:HyperLink>

 |</td>
<td>
<asp:HyperLink ID="hpTools" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Tools</asp:HyperLink>
 <img alt="getTools" class="style1" id="tools"
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" /> | 


</td>
<td>
<asp:HyperLink ID="hpResources" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Resources</asp:HyperLink>

 <img alt="GetResources" class="style1" 
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" /> |
</td>
<td>
<asp:HyperLink ID="hpQuickLinks" runat="server" Font-Bold="False" 
    Font-Size="Small" ForeColor="#F19005" >Quick Links</asp:HyperLink>

 <img alt="GetQuick Links" class="style1" 
        src="../../../_layouts/images/NMFSHeaderLinks/DropDown.png" />
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td> <div id="divtools" style="display:none">
            <asp:Menu ID="ToolsMenu" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://www.google.com" Text="Google" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://www.yahoo.com" Text="Yahoo" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div></td>
        <td>
        <div id="Reports">
            <asp:Menu ID="Menu1" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://www.google.com" Text="Static" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://www.yahoo.com" Text="Dynamic" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div>
        </td>
        <td>
        <div id="QuickLinks">
            <asp:Menu ID="Menu2" runat="server" BackColor="#F7F6F3" 
                DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" 
                ForeColor="#7C6F57" StaticSubMenuIndent="10px">
                <DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <DynamicMenuStyle BackColor="#F7F6F3" />
                <DynamicSelectedStyle BackColor="#5D7B9D" />
                <Items>
                    <asp:MenuItem NavigateUrl="http://Sparsh" Text="Sparsh" Value="Google">
                    </asp:MenuItem>
                    <asp:MenuItem NavigateUrl="http://webmail/owa" Text="Mail" Value="Yahoo">
                    </asp:MenuItem>
                </Items>
                <StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />
                <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                <StaticSelectedStyle BackColor="#5D7B9D" />
            </asp:Menu>
        </div>
        </td></tr>
</table>

but it is not going to the click function...
Please let me know how can i proceed....i tried with the image ID also.but not working

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

花间憩 2024-11-30 16:51:17

从脚本块中删除 src。另外,我不确定延迟加载是否会导致 $ 在执行脚本块时未定义。

Remove the src from the script block. Also, I'm not sure if deferred loading causes $ to be undefined at the time the script block is executed.

情独悲 2024-11-30 16:51:17

请从脚本块中删除 src。另外,我不确定延迟加载是否会导致 $ 在执行脚本块时未定义。

Please Remove the src from the script block. Also, I'm not sure if deferred loading causes $ to be undefined at the time the script block is executed.

初熏 2024-11-30 16:51:17

我不确定它是否会导致您出现问题,但如果您拥有一个带有 SRC 的脚本标签以及标签本身内的内容,这不会有任何帮助。您需要在 Jquery 周围有一个单独的标记,并且不提供 SRC 属性。

I'm not sure if its causing you problem, but it won't help that you have a script tag with an SRC and contents within the tag itself. You need a seperate tag around the Jquery with no SRC attribute supplied.

揪着可爱 2024-11-30 16:51:17

问题确实是由于延迟加载造成的,我在这篇文章中使用了类似的解决方案: 可以推迟 jQuery 的加载吗?

The problem is indeed due to deferred loading, I have used a similar solution to that in this post: Possible to defer loading of jQuery?

孤星 2024-11-30 16:51:17

我也有同样的问题。对我来说问题是该网站是 https 而 code.google 不是。使用本地副本,问题解决。我怀疑由于链接内容编辑器部分的呈现方式,“不安全内容”警告没有显示在我的计算机上。

I had the same problem. The issue for me was the site is https and code.google wasn't. Used local copy and the problem was solved. I suspect the 'unsecure content' warning did not show on my machine because of the way linked content editor parts are rendered.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文