![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
1
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
1
<
a
href
="javascript:void(0);"
onclick
="ChangePic();"
>
换图
</
a
>
问题就出现在上面这句话的void(0);如果把上面的那些代码修改为
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
1
<
img
id
="TestImg"
src
="http://duoduosuki.wt199.gvk.cn/TaobaoImages/1a71161c-6137-47b2-ba6d-2b39b0ff3a86.jpg"
/>
2
<
a
href
="javascript:ChangePic();"
>
换图
</
a
>
3![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<
script
type
="text/javascript"
language
="javascript"
>
4
function ChangePic()
5![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{
6
document.getElementById("TestImg").src = "http://duoduosuki.wt199.gvk.cn/TaobaoImages/738ee3c3-a3a3-438c-b6e0-c13bec51e3ea.jpg";
7
}
8
</
script
>
就不会出现这样的问题
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedSubBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
目前的解释可以认为是void(0)取消了图片加载的事件,所以如果涉及到图片的切换的时候需要注意这个问题。
同时这样的情况也存在于用innerHTML来替换图片的情况中。
但是也有人说是IE浏览器的问题,具体的我没有试验过,其实我到真的希望是这样,至少可以和客户解释为这个是IE的bug了,嘿嘿