可以在< style>上动态设置disabled = true.为什么不静态地? [英] disabled = true can be set dynamically on <style>. Why not statically?
问题描述
要禁用< style>
块,所有浏览器都允许设置 document.styleSheets [x] .disabled = true
.但是,只有IE允许在标记本身< style disabled ="true">
上设置此属性.在其他浏览器中是否有解决方法?动态完成的事情也不能静态完成似乎很奇怪.
To disable <style>
blocks, all browsers allow setting document.styleSheets[x].disabled = true
. However, only IE allows this property to be set on the tag itself, <style disabled="true">
. Is there a workaround for this in other browsers? It seems odd that something done dynamically can't also be done statically.
推荐答案
扩展到@lampyridae的 media
答案,您可以使用 not
否定媒体选择器.要静态禁用样式标签,请使用 media ="not all"
,该标签在Chrome 79中适用于我.
Extending on the media
answer by @lampyridae, you can negate a media selector using not
. To disable a style tag statically, I use media="not all"
, which works for me in Chrome 79.
这篇关于可以在< style>上动态设置disabled = true.为什么不静态地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!