[转]动态改变图片的useMap属性导致IE假死或崩溃!
2010-01-25 16:55
399 查看
项目中需要动态生成一个统计图形,在统计图上用MAP标签生成图形的tooltip,由于图片是通过AJAX方式加载的,每次的图形都不同,则相应的MAP信息也就不同了,于是问题就出现了:
每次更改图片的MAP时(img.useMap = "#mymap"),在我本机都是没问题的,很流畅,但别人的部分机器上就会出现IE假死的情况,甚至崩溃,很是郁闷,今天到Google了一下,发现确实有这个问题,而且仅限于IE7,摘抄如下:
引用
UseMaps Crash IE When Changed
By Shawn Olson
Posted on 03.31.08
Dynamically changing an image's usemap property can cause Internet Explorer to crash completely. You can encounter this problem if you have an image that is using an image map and then switch the image's usemap (and/or useMap) property to use an alternative image map. The crash happens when the image map you are changing to does not have as many area nodes as the current image map.
The solution to this problem is to add area nodes into the image map you are changing to before you change the image's usemap property. You can do this by running equalizeUseMaps() which is a function included in the JavaScript referenced below.
function equalizeUseMaps(currentUseMap,nextUseMap)
This function will add blank AREA nodes to nextUseMap if currentUseMap has more area nodes than nextUseMap has.
To use this function, add the following line of code to your HTML head:
<script type="text/javascript" src="http://www.shawnolson.net/scripts/areamap.js"></script>
Please include credit when using this script and read this site's Terms & Conditions before using.
原文地址为:http://www.shawnolson.net/a/1395/usemaps-crash-ie-when-changed.html
当图片将要使用的MAP标签中的AREA节点数量小于当前所用MAP的AREA节点数量时,IE就完蛋了。
解决办法就是在改变useMap属性之前,判断两个MAP中的AREA节点数量是否相等,如果不相等,则动态创建AREA节点,使他们相等。
每次更改图片的MAP时(img.useMap = "#mymap"),在我本机都是没问题的,很流畅,但别人的部分机器上就会出现IE假死的情况,甚至崩溃,很是郁闷,今天到Google了一下,发现确实有这个问题,而且仅限于IE7,摘抄如下:
引用
UseMaps Crash IE When Changed
By Shawn Olson
Posted on 03.31.08
Dynamically changing an image's usemap property can cause Internet Explorer to crash completely. You can encounter this problem if you have an image that is using an image map and then switch the image's usemap (and/or useMap) property to use an alternative image map. The crash happens when the image map you are changing to does not have as many area nodes as the current image map.
The solution to this problem is to add area nodes into the image map you are changing to before you change the image's usemap property. You can do this by running equalizeUseMaps() which is a function included in the JavaScript referenced below.
function equalizeUseMaps(currentUseMap,nextUseMap)
This function will add blank AREA nodes to nextUseMap if currentUseMap has more area nodes than nextUseMap has.
To use this function, add the following line of code to your HTML head:
<script type="text/javascript" src="http://www.shawnolson.net/scripts/areamap.js"></script>
Please include credit when using this script and read this site's Terms & Conditions before using.
原文地址为:http://www.shawnolson.net/a/1395/usemaps-crash-ie-when-changed.html
当图片将要使用的MAP标签中的AREA节点数量小于当前所用MAP的AREA节点数量时,IE就完蛋了。
解决办法就是在改变useMap属性之前,判断两个MAP中的AREA节点数量是否相等,如果不相等,则动态创建AREA节点,使他们相等。
相关文章推荐
- jquery动态改变onclick属性导致失效的问题解决方法
- JavaScript之动态改变img标签里面的src属性实现图片的循环切换
- 用js动态的改变img标签里面的src属性实现图片的循环切换
- Android动态改变button顶部图片即drawableTop属性
- 解决javascript动态改变img的src属性图片不显示问题
- 通过html5的range属性动态改变图片的大小
- 解决javascript动态改变img的src属性图片不显示问题
- 通过html5的range属性动态改变图片的大小
- jquery动态改变onclick属性导致失效的问题解决方法
- jquery动态改变onclick属性导致失效的问题解决方法
- javascript动态改变img的src属性图片不显示的解决方法
- jquery动态改变onclick属性导致失效的问题解决方法
- 解决javascript动态改变img的src属性图片不显示问题
- javascript动态改变img的src属性图片不显示的解决方法
- 解决javascript动态改变img的src属性图片不显示问题
- 解决javascript动态改变img的src属性图片不显示问题
- Android 在onActivityResult()中设置图片setImageResource(resId) 或者改变view属性,不成功的解决办法
- 20110107 学习记录:动态指定iframe的scr属性 & IE和Firefox的js兼容性整理 & iframe自适应高度
- Unity的动态字库字体超出字库图片尺寸导致字体花屏
- 在IE中用js改变table的innerHTML属性报“未知的运行时错误”