jquery prepend在除IE7之外的所有borwsers中工作

时间:2010-09-16 21:29:27

标签: jquery internet-explorer prepend

Arrg!到目前为止,我的网站(正在进行中)在我测试过的所有浏览器(firefox,safari,chrome和IE8)中工作得很好,但在IE7中却没有(我不知道IE6或其他浏览器)....我我不是肯定的,但我认为这个问题与我在jQuery中使用prepend()有关。主要问题是主菜单(应显示在徽标左侧的蓝色水平栏中)以及右上角的搜索框,两者都使用前置添加。在IE7中还有其他问题,所以我不确定我是否正在考虑它是否来自jQuery,或者在我目前的css混乱中是否存在拼写错误!

这是我用于主菜单的脚本,它在IE7中不起作用,但在其他浏览器中有效 - 有没有人在这里看到问题?

<script type="text/javascript">
<!--
$(function() {

/* ************************************** */
/* main menu */
/* ************************************** */
$("#bannerAreaWrapper").prepend("<div id='MainMenu'><a id='neutralsBtn' class='MainMenuModule' href='/neutrals-overview/'>Neutrals</a> <span class='bullet'>•</span> <a id='practicesBtn' class='MainMenuModule' href='/practices/'>Practices</a> <span class='bullet'>•</span> <a id='locationsBtn' class='MainMenuModule' href='/locations/'>Locations</a></div>");

});
-->
</script>

以下是该网站的链接:http://www.agencydr.squarespace.com 感谢帮助!!

2 个答案:

答案 0 :(得分:3)

IE7在您的网站中发现了两个javascript错误:

Expected identifier, string or number line 139
$('#LocationsMapWrapper').hover(function() {
   $('#LocationsMapWrapper #MapImage').animate({
      width: 600,
      height: 375,
      marginLeft: 550,
      marginTop: -20,                <---- remove comma
   }, "slow", "easeOutQuad");
 }

 'document.getElementById(...)' is null or not an object line 355
Shadowbox.setup(document.getElementById('Map').getElementsByTagName('area'), {width : 450, height : 400});

答案 1 :(得分:1)

当我通过IE7上的开发工具栏脚本控制台运行它时,你的prepend函数工作正常,尽管它在加载时不起作用。 IE8上有一个js错误,IE7上有两个错误。 IE7上的附加功能与此功能有关:

$('#LocationsMapWrapper').hover(function() {
   $('#LocationsMapWrapper #MapImage').animate({
      width: 600,
      height: 375,
      marginLeft: 550,
      marginTop: -20,
   }, "slow", "easeOutQuad");
 }

139行具体

尝试删除此内容并查看导航是否在页面加载时按预期工作

修改

砰的一声,明白了。

尝试在'marginTop:-20'后删除逗号 最后一个元素不应该有这个,认为它会影响所有旧浏览器