Assuming:
const body = document.getElementsByTagName('body')[0];
const iframe = document.createElement('iframe');
iframe.src = protocol + settings.scriptUrl + a;
iframe.height = 1;
iframe.width = 1;
iframe.scrolling = 'no';
iframe.frameborder = 0;
iframe.setAttribute("style", "display:none");
body.appendChild(iframe);
An error message of
TypeError: Attempted to assign to readonly property.
pops up on the line where iframe.style =
is located while testing in Safari with strict mode enabled.
It seems logical to require a setter for .style
, but no concrete information can be found on this requirement nor any suggestions on what should be done instead.
After some research, I stumbled upon CSSStyleDeclaration.setProperty(), which might be the solution needed. However, uncertainty remains regarding browser support, compatibility with strict mode, and variations between new and old browsers.