window.getComputedStyle() returns null inside an iframe with display: none

来源:互联网 发布:大班美工 剪纸花瓣 编辑:程序博客网 时间:2024/06/05 05:48
<script type="text/javascript">
  if (/firefox/i.test(navigator.userAgent)){
   window.oldGetComputedStyle = window.getComputedStyle;
   console.log("a");
   window.getComputedStyle = function (element, pseudoElt) {
      var t = window.oldGetComputedStyle(element, pseudoElt);
        console.log(t);
      if (t === null) {

         return {
            getPropertyValue: function(){}
         };
      } else{

         return t;
      }
   };
}
</script>
0 0