Chrome下获取外部样式表rules为空的问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/marcelwu/article/details/78902895

在跑这些代码时,所有的文件路径都是本地的路径

如果样式表为外部样式表,如:

<link rel="stylesheet", type="text/css" href="style.css" />

那么

document.styleSheets[0].cssRules

返回null;

在火狐下则不会。

信息来源:https://stackoverflow.com/questions/46356349/document-stylesheetsx-cssrules-are-null

猜你喜欢

转载自blog.csdn.net/marcelwu/article/details/78902895