可以在< style>上动态设置disabled = true.为什么不静态地? [英] disabled = true can be set dynamically on <style>. Why not statically?

查看:40
本文介绍了可以在< style>上动态设置disabled = true.为什么不静态地?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要禁用< 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.

这篇关于可以在&lt; style&gt;上动态设置disabled = true.为什么不静态地?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆