2011-12-24 61 views

回答

0

我用rgba颜色一招:

try {elem.style.background = "rgba(255,255,255,0.5)";} 
catch(e) {elem.style.background = "#cccccc";} 

您可以轻松地适应这个问题的方法:

try {elem.style.color = "inherit";} // or "currentColor" which is synonymous here 
catch(e) {elem.style.color = "red";} // or whatever fallback you want 

或者,tr Ÿ这个代替:

if(typeof getComputedStyle == "undefined") 
    getComputedStyle = function(elm) {return elm.currentStyle;} 
elem.style.color = getComputedStyle(elem.parentNode).color; 

这将让父节点,这是基本相同inherit ING的计算样式(currentStyle中老年IE)。

+0

谢谢。正是我需要的! – Luc 2011-12-27 08:40:41

+0

如果您的问题已被解答,请接受答案。 – 2011-12-27 16:08:29