0
function getStyle(el, cssprop) {
  if (el.currentStyle) { // IE
    return el.currentStyle[cssprop];
  } else if (document.defaultView && document.defaultView.getComputedStyle) { // Firefox
    return document.defaultView.getComputedStyle(el, "")[cssprop];
  } else { // try and get inline style
    return el.style[cssprop];
  }
}

呼び出されると、このエラーが発生します このエラーが発生します

NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument arg 0 [nsIDOMWindow.getComputedStyle]
return document.defaultView.getComputedStyle(el, "")[cssprop];

したがって、関数呼び出しはfindOpacity(window.thirddiv,1). findOpacityを呼び出しますgetStyle。のコードfindOpacityは次のようになります。

function findOpacity(node, minValue) {
    if(node==document.body) {
        return getStyle(document.body, 'opacity') < minValue
            ? getStyle(document.body, 'opacity')
            : minValue;
    } else {
        return findOpacity(node.parentNode, getStyle(node.parentNode, 'opacity'))
            < minValue
            ? findOpacity(node.parentNode, getStyle(node.parentNode, 'opacity'))
            : minValue;
    }
}
4

1 に答える 1