Javascript无法从母版页运行

Javascript not working from masterpage

本文关键字:母版页 运行 Javascript      更新时间:2023-11-03

我有一个母版页和一个JS文件,我在母版页中添加了一个指向javascript文件的链接,但在任何使用母版页的页面上,JS都不起作用。

我在一个单独的页面上单独尝试了代码,它很有效。

<head runat="server">
    <title></title>
    <link href="../styles/StyleSheet1.css" rel="stylesheet" />
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <script src="../Scripts/Menu.js"></script>
    <script type="text/javascript">
        function openNewWin(url) {
            var x = window.open(url, 'mynewwin', 'toolbar=no,directories=no,location=no,menubar=no,left=0,top=0,resizable=no,status=no');
            x.focus();
        }
    </script>

</head>

菜单.JS:

$(function () {
    //When opening the page all level 2 and level 3 items must be hidden.
    $(function () {
        hideitems();
    })
    function hideitems() {
        $('h10').hide();
        $('h11').hide();
        $('h12').hide();
        $('h13').hide();
    }
    //Financial Click
    $('h7').click(function () {
        hideitems();
            $('h10').slideToggle();
            $('h11').slideToggle();
            $('h12').slideToggle();
        });
    //Container Click
        $('h8').click(function () {
            hideitems();;
            $('h13').slideToggle();
        });
    })

我认为这是文件路径问题。你能按照这里给出的步骤吗

ASP.Net母版页和文件路径问题

如前所述是一个路径问题。

你确定文件夹是脚本而不是脚本吗?

打开检查器并获取引用的链接,也可能会在控制台中出现错误