0

我有一个包含一些按钮(div)的 DIV,每个按钮都设置为onmouseover更改所有相应 div 的属性。我使用 Dreamweaver 行为的东西来创建它,因为我对 Javascript 非常陌生。好吧,我的问题是;它在 Chrome、Firefox 和 Safari 中完美运行……但在 Internet Explorer 中没有任何作用。我知道从哪里开始。有问题的网站在这里

4

1 回答 1

0

所以你的问题在于这个函数:

function MM_changeProp(objId,x,theProp,theValue) { //v9.0
  var obj = null; with (document){ if (getElementById)
  obj = getElementById(objId); }
  if (obj){
    if (theValue == true || theValue == false)
      eval("obj.style."+theProp+"="+theValue);
    else eval("obj.style."+theProp+"='"+theValue+"'");
  }
}

具体来说,这一行:

else eval("obj.style."+theProp+"='"+theValue+"'");

当您尝试更改属性时,IE8 最终会窒息backgroundImage,它会尝试评估:

obj.style.backgroundImage=' url(../images/homepointer1.png)'

并抛出

SCRIPT87: Invalid argument. 

我认为这是因为您在值中有一个额外的空格并且没有在 URL 字符串周围使用引号。基本上你的代码中有这样的东西:

' url(../images/homepointer2.png)'

您需要修复它,使其看起来像这样:

'url("../images/homepointer2.png")'

我没有简单的方法来验证这一点,因此修复可能不正确,但这绝对是您的问题所在。顺便说一句,它只在 IE7/IE8 中被破坏,它在 IE9 中运行良好。

于 2012-08-18T04:25:11.567 回答