开发者

How do I get ignored style properties in js?

开发者 https://www.devze.com 2023-01-23 15:33 出处:网络
I am doing some work on a CSS/JS plugin. I want to开发者_JAVA百科 be able to write something like this in my stylesheet:

I am doing some work on a CSS/JS plugin. I want to开发者_JAVA百科 be able to write something like this in my stylesheet:

.whatever {
  background: 
    -custom-renderer("ctx.beginPath(); ctx.moveTo(0, 40); ctx.lineTo(240, 40); ctx.moveTo(260, 40); ctx.lineTo(500, 40); ctx.moveTo(495, 35); ctx.lineTo(500, 40); ctx.lineTo(495, 45);")
    repeat-x;
  background: rgb(30, 30, 30); /* fallback */

I would need to access this property with Javascript and rewrite it with a different property. Now the problem is that all of the methods I know of (document.styleSheets[1].cssRules, document.defaultView.getMatchedCSSRules, etc.) tend to show only the fallback property (which is normally great behavior).


Why don't you append the modified CSS rules as a "<style>" element into the document head..

Take a look on that..

http://jonraasch.com/blog/javascript-style-node

*you can set an ID on the "<style>" element to easily modify it with javascript

0

精彩评论

暂无评论...
验证码 换一张
取 消