--- title: StyleSheet.disabled slug: Web/API/StyleSheet/disabled tags: - API - CSSOM - Disabled - Property - Reference translation_of: Web/API/StyleSheet/disabled --- <div>{{APIRef("CSSOM")}}</div> <div>{{domxref("StyleSheet")}}接口的 <strong><code>disabled</code> </strong>属性用于决定样式表是否被禁用于文档。</div> <div>样式表被禁用可能由于这个属性被手动设置为 <font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">true</span></font>,也可能是因为样式表是未激活的<a href="https://wiki.developer.mozilla.org/en-US/docs/Web/CSS/Alternative_style_sheets">alternative style sheet</a>。注意 <code>disabled == false</code> 并不保证样式表一定生效(例如它可能被移除出文档)。</div> <h2 id="Syntax" name="Syntax">语法</h2> <pre class="syntaxbox"><em>bool</em> = stylesheet.disabled </pre> <h2 id="Example" name="Example">例子</h2> <pre>// 如果样式表被禁用 if (stylesheet.disabled) { // 添加行内样式 } </pre> <h2 id="Specification" name="Specification">规范</h2> <table class="standard-table"> <thead> <tr> <th scope="col">规范</th> <th scope="col">状态</th> <th scope="col">注释</th> </tr> </thead> <tbody> <tr> <td>{{SpecName("CSSOM", "#dom-stylesheet-disabled", "StyleSheet.disabled")}}</td> <td>{{Spec2("CSSOM")}}</td> <td>No change from {{SpecName("DOM2 Style")}}.</td> </tr> <tr> <td>{{SpecName("DOM2 Style", "stylesheets.html#StyleSheets-StyleSheet-disabled", "StyleSheet.disabled")}}</td> <td>{{Spec2("DOM2 Style")}}</td> <td>Initial definition.</td> </tr> </tbody> </table> <h2 id="Browser_compatibility">Browser compatibility</h2> <p>{{Compat("api.StyleSheet.disabled")}}</p>