UseMaps Crash IE When Changed
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.
2011-11-11 I haven't had IE7 installed in a while (we're at IE9 now) and I'm not sure this bug still exists anymore.
- Free Useful Javascripts
Links to articles that give free javascript code or javascript examples.
- Altering CSS Class Attributes with JavaScript
- Change HTML Styles with JavaScript
- Select Some Checkboxes JavaScript Function
- Select All Checkboxes in a Form with JavaScript
- Get a Form Element's Label with JavaScript
- Select Radio Inputs JavaScript
- UseMaps Crash IE When Changed
- Hide Select Menus JavaScript
- Manipulating Element Styles Based on CSS Classes Using Prototype
- Compare Values with Arbitrary Comparison Operator
- Related Topics