最佳答案
我通过maphilight源代码进行调试,发现IE8在为新创建的样式表添加规则时会卡住。当我在 Google 上搜索这个特定问题时,我发现了 bug report on OpenLayer's track 。错误报告有一个补丁,我在 maphilight 插件上使用了这个补丁来修复它。
这是您需要执行的操作。打开jquery.maphilight.js(未压缩源)并转到第63行,您将看到类似以下内容:
document.createStyleSheet().addRule("v\\:*", "behavior: url(#default#VML); antialias: true;"); //IE8 chokes on this line.
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
将上面的内容替换为以下内容:
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
var style = document.createStyleSheet();
var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox'];
$.each(shapes,
function()
{
style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true");
}
);
它现在应该可以在 IE8 中运行。这是证据,看看怀俄明州是如何突出显示的。
我不确定这是否适用于 IE6 和 IE7。您必须亲自测试一下。如果在 IE6 和 IE7 中出现此问题,则只有在浏览器为 IE8 时才需要打此补丁。
再次将上述补丁归功于原作者。我只在maphilight插件中调试了这个问题。
关于jquery - JQuery Hilight 插件有替代品吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1169162/