日期:2014-05-17  浏览次数:20403 次

为什么我加入onload事件,会影响我的二级联动
没加入onload事件时,我的二级联动是正确的,但是加入javascript代码后会影响二级联动,这是为什么?这两个之间应该没联系吧!应该怎么修改?
<script type="text/javascript">
  window.onload = function() {
  var a = document.getElementById("loading");
  a.parentNode.removeChild(a);
  }
  document.write('<img style="position:absolute; left:50%; top:50%;" alt="Loading..." src="../Images/hourglass.gif" id="loading" />');
   
  </script>


------解决方案--------------------
在一个页面里面如果多处用到了window.onload 那么后面的会覆盖掉前面的,从而导致部分js无法正常执行,因此,你需要将这些代码集中在一个方法中,然后在由window.onload调用
------解决方案--------------------
探讨

我这个页面就这么一个onload

------解决方案--------------------
跌出来联动的代码。
------解决方案--------------------
你的联动代码是不是使用了
id="loading"
id重复了?还是缺少了?

这样的问题得看代码。
正常情况下是不行影响的
------解决方案--------------------
在ddlSystemID的onchanged事件中调用那段js吧。
------解决方案--------------------
document.write('<img style="position:absolute; left:50%; top:50%;" alt="Loading..." src="../Images/hourglass.gif" id="loading" />');
删除,

<img style="position:absolute; left:50%; top:50%;" alt="Loading..." src="../Images/hourglass.gif" id="loading" />放在body里面