what's the difference bewteen document.defaultView.getComputedStyle and window.getComputedStyle

前端 未结 1 661
天涯浪人
天涯浪人 2021-01-04 19:19

when get a element\'s style, we always use

if(document.defaultView && document.defaultView.getComputedStyle) to check whether the browser suppo

相关标签:
1条回答
  • 2021-01-04 19:43

    So in short, the reason why we use document.defaultView && document.defaultView.getComputedStyle is that we want a cross-browser working-on-every-element method of checking whenever it supports fetching computed styles.

    Simple if(window.getComputedStyle) would fail for iframes in Firefox 3.6 (according to article linked in comment by Alex K.).

    0 讨论(0)
提交回复
热议问题