zoukankan      html  css  js  c++  java
  • [转]动态改变图片的useMap属性导致IE假死或崩溃!

        项目中需要动态生成一个统计图形,在统计图上用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节点,使他们相等。

  • 相关阅读:
    用户代理列表--爬虫伪装浏览器访问用
    python爬虫解析页面数据的三种方式
    requests模块的使用
    Python pip源更改
    个人博客项目开发
    Django之中间件
    Django之发送邮件
    Django组件之用户认证组件
    Django之Cookie与session
    Django组件之分页器
  • 原文地址:https://www.cnblogs.com/Aricc/p/1656009.html
Copyright © 2011-2022 走看看