mortenma71
mortenma71

Reputation: 1286

How to use CSSStyleSheet.insertRule() in Internet Explorer properly?

I am getting a "IndexSizeError" error in Internet Explorer 11 using this code:

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

According to https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/insertRule the index parameter is optional.

Upvotes: 1

Views: 350

Answers (1)

mortenma71
mortenma71

Reputation: 1286

In IE11 the error is fixed if I add the index parameter:

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

related: How to use CSSStyleSheet.insertRule() properly?

Upvotes: 2

Related Questions