javascript - 未确定的 Javascript 错误

标签 javascript

我已经实现了 .NET 登录功能,但每当用户单击登录 anchor 按钮访问 Login.aspx 时,我都会收到 JavaScript 错误。

此 anchor 菜单按钮是在母版页中定义的 CSS 菜单的一部分。

当我在本地运行时,错误指示:

'ddmegamenu' is undefined

但是这个脚本是在 MasterPage 中定义的:

所有的子页面都可以看到这个脚本,包括Login.aspx:

<script type="text/javascript">
    ddmegamenu.docinit({
        menuid: 'solidmenu',
        dur: 200 //<--no comma after last setting
    })
</script>

这是开发网站:http://www.virtualpetstore.com

Login.aspx 位于单独的帐户目录中,但我认为这不是问题。

如果有人能看到这个问题,我将不胜感激。

最佳答案

您收到错误是因为您没有正确引用 Login.aspx 页面上的 JS 文件。这是控制台显示的内容(除了您发布的错误之外):

GET http://www.virtualpetstore.com/Account/js/jquery.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery-1.5.min.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery-ui.min.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery.serialScroll-min.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/ddmegamenu.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery.scrollTo-min.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery.simplemodal.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery.cycle.min.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/jquery.actual.js 404 (Not Found)
GET http://www.virtualpetstore.com/Account/js/contact.js 404 (Not Found)

确保您的 JS 文件正在加载,您的错误很可能会消失。

提示:您的脚本标签应如下所示:

<script type="text/javascript" src="/js/ddmegamenu.js"></script>

关于javascript - 未确定的 Javascript 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9840525/

相关文章:

JavaScript NaN 点击问题

javascript - html 表单 - `required` 属性未通过 onclick 确认触发

javascript - 在一些有趣的 JavaScript 代码中访问 element.innerText 而不做任何其他事情有什么意义?

javascript - 通过 ajax 发送同名多个复选框值

javascript - 如何在列表项中创建新的 Div

javascript - 如何在javascript中从数组中删除某些数字元素

javascript - 如何将 PhoneGap 与 Worklight 结合使用?

javascript - 安装Node 6后出错,npm ERR!无效版本 : 1. 0.5beta

javascript - 如何在 Backbone JS 中将多个路由定向到同一个方法?

javascript - 如何在输入字段模型属性的 Angular 中制作 getter 和 setter?