如何在Internet Explorer中正确使用CSSStyleSheet.insertRule()?

使用以下代码,我在Internet Explorer 11中收到“ IndexSizeError”错误:

var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('td {overflow: visible}');

根据https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule,index参数是可选的。

hhhhttty 回答:如何在Internet Explorer中正确使用CSSStyleSheet.insertRule()?

在IE11中,如果添加索引参数,则错误已修复:

var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('td {overflow: visible}',0);

相关:How to use CSSStyleSheet.insertRule() properly?

本文链接:https://www.f2er.com/3166109.html

大家都在问