javascript 菜单在 explorer 8 中无法正确执行(在 chrome 和 explorer 8 兼容模式下工作正常)
我正在构建一个网站模板,您可以在这里看到:
http://davewallace.net/sunschool/ template-test.asp
一切都很顺利,直到我在电脑上检查了资源管理器(8)(我通常在电脑上使用chrome),
问题与(左侧)侧菜单有关...
我注意到点击后侧面菜单中的第二个父项(即在一个会话期间,在单击另一个父菜单项后单击一个父菜单项)并且每次单击连续的父菜单项时,被单击的前一个父菜单的内容在应该消失时不会消失,而是停留在屏幕上但向上移动,与顶部父项对齐。在 Chrome 中一切正常,但这仅在资源管理器中有效。
* 更新! * 我刚刚做了一些更多的研究,并在运行“兼容模式”的资源管理器中再次查看了该页面,它工作得很好!所以我已将问题隔离到仅在标准模式下运行的 Explorer 8。
另一个更新*感谢 Ibu,我修复了几个(相对较小的)html 错误她认为这可能是造成问题的原因。不幸的是,情况并非如此 *** 我相信这是一个 javascript 问题,可能是侧面菜单和顶部菜单代码之间存在某种代码冲突...我真的正在尽力解决这个问题,但会喜欢一点 javascript 大师,请下雨:)
我注意到,这几乎肯定是与用于显示顶部菜单下拉菜单的代码发生代码冲突。我知道这一点是因为我之前在网站上使用过侧菜单代码(没有其他下拉菜单代码)并且它在 Chrome 和资源管理器中都可以正常工作。
我已经包含了下面代码的链接 - 它组织得相当好*,希望有人能轻松帮助我调试!
http://davewallace.net/stack-overflow/code.zip
侧边菜单 JavaScript是 css-dropdowns.js,我怀疑此文件中的某些内容需要修改
*不幸的是,此文件中的某些代码没有换行符,可能难以阅读。我为此道歉。我没有编写代码:)
其他 javascript 文件都与顶部菜单相关。
预先感谢您,
希望它不会太棘手!
最好的问候,
dw
i'm building a website template which you can see here:
http://davewallace.net/sunschool/template-test.asp
all was going well until i checked in explorer (8) on pc (i normally use chrome on pc)
the problem relates to the (left hand) side menu...
i noticed that upon clicking a second parent item in the side menu (that is during one session, clicking on one parent menu item after clicking on another) and every successive parent menu items clicked, the contents of the former parent menu that was clicked would not disappear when they should, instead staying on screen but moving up, aligned with the top parent item. all works fine in chrome however, this is only in explorer.
* update! * i just did some more research and viewed the page again in explorer running "compatibility mode" and it worked fine! so i have isolated the problem down to explorer 8 running in standard mode only.
another update * thanks to Ibu, I have fixed a couple of (relatively minor) html errors which she thought may have been causing the problem. unfortunately this was not the case *** I believe it is a javascript issue and probably some kind of code clash between side menu and top menu code... I really am trying to do my best to resolve this but would love a bit of javascript guruness to rain down please :)
i note that it is almost definitely a code clash with code used to display the top menu dropdowns. i know this because i've used the sidemenu code before on a site by itself (without other dropdown menu code) and it works fine in both chrome and explorer.
i have included a link to the code below - it is all fairly well organised* and hopefully easy for someone to help me debug!
http://davewallace.net/stack-overflow/code.zip
the side menu javascript is css-dropdowns.js and i suspect it is something in this file that needs to be amended
*unfortunately some of the code in this file does not have line breaks and may be hard to read. i apologise for this. i did not write the code :)
the other javascript files all relate to the top menu.
thanking you in advance,
hope its not too tricky!
best regards,
dw
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,既然我浏览了你的测试页面来看看问题是什么,JavaScript 是最不重要的问题:
不正确的 html 会导致其他问题。
这是我在控制台中发现的内容:
因此修复这些错误很可能会修复您的其他 js 错误
Ok since i went through your test page to see what the problem is, the javascript is the least of the problem:
Having incorrect html will cause other issues.
here is what i found in the console:
so fixing those error will very likely fix your other js errors
我自己“解决”了它!是的,
虽然我知道这不是最完美的解决方案,但它确实有效,考虑到我在这方面花费了多少时间,而且我没有得到报酬来建立这个网站,这对我来说已经足够好了!
我有点惊讶没有人能提出这个建议,无论如何我自己解决了这个问题,所以我希望我能得到一些童子军积分:)
解决方案如下:
在我的头部内容中添加了以下内容:
嘿,普雷斯托。 IE 8 现在模拟 IE 7 并且问题已得到解决。
当然,最终我知道代码中仍然存在一些 IE 8 不喜欢的问题,如果有人愿意向我指出,我将不胜感激。但现在,我是一个快乐的小伙子。感谢@Ibu 早些时候帮助我清理这些 HTML 错误!
I "solved" it myself!! Yaaay
Whilst I know its not the most perfect solution, it works, and thats good enough for me considering how much time I've spent on this and the fact that I'm not getting paid to build this website!
Am a bit surprised no-one else could suggest this, anyway I worked it out for myself so I hope i get a few boy scout points :)
The solution was as follows:
Added the following to my head content:
Hey Presto. IE 8 now emulates IE 7 and the problem is fixed.
Of course ultimately I know that there is still some issue in the code that IE 8 does not like, and if anyone cares to point it out to me, I'd be most grateful. But for now, I'm a happy chappy. Thanks @Ibu for your assistance earlier on in helping me clean up those HTML errors!