jjzjj

insertRule

全部标签

javascript - 类型 'addRule' 上不存在属性 'insertRule' 和 'StyleSheet'

我有如下typescript代码:-exportfunctiongetRootWindow():Window{returnwindow.top;}exportfunctiongetRootDocument():HTMLDocument{returngetRootWindow().document;}declareglobal{interfaceDocument{documentMode?:any;}}exportfunctionisBrowserIE(){returngetRootDocument().documentMode;}exportfunctionaddCssRule(css

javascript - Chrome 64 未捕获的 DOMException : Failed to execute 'insertRule' on 'CSSStyleSheet' : Cannot access StyleSheet to insertRule

啊!我的网站在Chrome中损坏了。在控制台中获取此消息:UncaughtDOMException:Failedtoexecute'insertRule'on'CSSStyleSheet':CannotaccessStyleSheettoinsertRule指向这行代码,来自第三方插件:document.styleSheets[0].insertRule(rule,0);head中定义的样式表: 最佳答案 我们认为对Chromium的这种promise是我们问题的根本原因:UpdatebehaviorofCSSStyleSheett

javascript - 未捕获的 TypeError : Failed to execute 'insertRule' on 'CSSStyleSheet' : 2 arguments required, 但只有 1 个存在

关闭。这个问题不符合StackOverflowguidelines.它目前不接受答案。关于您编写​​的代码问题的问题必须在问题本身中描述具体问题—并且包括有效代码以重现它。参见SSCCE.org寻求指导。关闭9年前。Improvethisquestion最新版本的GoogleChrome和Opera会抛出此错误:UncaughtTypeError:Failedtoexecute'insertRule'on'CSSStyleSheet':2argumentsrequired,butonly1present.知道这个新错误的来源以及如何修复吗?

javascript - 如何正确使用 CSSStyleSheet.insertRule()?

我不知道我哪里错了:/。当我运行这段代码时,我得到的只是一个空白元素。我似乎无法让insertRule方法执行任何操作(甚至不产生错误)。我错过了什么吗?Testvarsheet=(function(){//Createthetagvarstyle=document.createElement("style");//WebKithackstyle.appendChild(document.createTextNode(""));//Addtheelementtothepagedocument.head.appendChild(style);returnstyle.sheet;})();

javascript - 为什么使用CSSOM的insertRule后样式不可见,样式标签不能重新追加

如果我使用insertRule通过CSSOM添加样式我注意到两件事。在Firebug中查看时,添加的样式不会出现在html中。如果样式标签被附加(例如:从头部移动到body)到另一个元素(发生在Firefox和Chrome中),则添加的样式不起作用。如果样式是在附加标签之后添加的,那么它们就可以工作。它们仍然没有显示在Firebug中。附加工作表时必须重新分配(重新获取?)这使得它看起来更奇怪。对于在Firebug中不显示这可能是Firebug的一个怪癖,但未动态添加的常规样式会显示。对于在附加后不起作用的样式,我想知道这是否是标准,因为这发生在Firefox和Chrome中。查看标准

javascript - 为什么使用CSSOM的insertRule后样式不可见,样式标签不能重新追加

如果我使用insertRule通过CSSOM添加样式我注意到两件事。在Firebug中查看时,添加的样式不会出现在html中。如果样式标签被附加(例如:从头部移动到body)到另一个元素(发生在Firefox和Chrome中),则添加的样式不起作用。如果样式是在附加标签之后添加的,那么它们就可以工作。它们仍然没有显示在Firebug中。附加工作表时必须重新分配(重新获取?)这使得它看起来更奇怪。对于在Firebug中不显示这可能是Firebug的一个怪癖,但未动态添加的常规样式会显示。对于在附加后不起作用的样式,我想知道这是否是标准,因为这发生在Firefox和Chrome中。查看标准

javascript - Chrome 突然停止接受 insertRule()

我有一个HTML5游戏已经运行了好几个星期了。突然,大约一个小时前,它将不再在Chrome中运行。我将问题缩小为仅在Chrome中发生的JavaScript错误。我在这里隔离了上述代码:http://jsfiddle.net/quM3L/...第4行产生错误:varstyle=document.documentElement.appendChild(document.createElement("style"));varrule="score_10_typing{from{width:0}to{width:11em}}";if(CSSRule.KEYFRAMES_RULE){//W3C