Coder Social home page Coder Social logo

Comments (8)

erfanimani avatar erfanimani commented on June 26, 2024

Hmm interesting, I'm getting that as well, but only in IE and Firefox (not in Chrome).

The problem lies in this part:

          var test = $('<div/>').css({
              position: 'absolute',
              'font-size': '14.1px'
            }).appendTo(document.body).get(0),
            computedStyle = window.getComputedStyle( test, null );

It seems test always returns undefined, but Chrome doesn't throw an exception, whereas Firefox and IE do.

I think the issue is that @multiformeingegno and I are including the script in the head of our html, instead of before the body end tag. In our case body doesn't exist yet, and appendTo(document.body) returns undefined!

Let me just try to confirm this..

from bigtext.

erfanimani avatar erfanimani commented on June 26, 2024

Ok yeah, that was the problem - moving the script to before the body end tag worked. Not sure if you'd classify that as a bug or not! :)

from bigtext.

 avatar commented on June 26, 2024

I can confirm this. The plugin is unusable on Firefox/Yosemite.

Here's the fix:

          var computedStyle="";
          try{
          var test = $('<div/>').css({
              position: 'absolute',
              'font-size': '14.1px'
            }).appendTo(document.body).get(0),
            computedStyle = window.getComputedStyle( test, null );
          }catch(e){
            //do nothing
          }
          return computedStyle ? computedStyle.getPropertyValue( 'font-size' ) === '14px' : true;

from bigtext.

zachleat avatar zachleat commented on June 26, 2024

The plugin needs to run either on DOMContentLoaded or onload. I’ll probably build this into the plugin eventually so that it handles it transparently.

from bigtext.

fezzik1620 avatar fezzik1620 commented on June 26, 2024

I can confirm seeing this on Chrome beta 41.0.2272.74. An associate of mine on the same network, loading the same internal page not using the beta release of Chrome is not seeing this behavior.

from bigtext.

ashinzekene avatar ashinzekene commented on June 26, 2024

Window.getComputedStyle does not work when you use document.querySelector. it works when u use getElementById

from bigtext.

muskanbardia1 avatar muskanbardia1 commented on June 26, 2024

how to resolve this error in react?

from bigtext.

muskanbardia1 avatar muskanbardia1 commented on June 26, 2024

Window.getComputedStyle: Argument 1 is not an object.

from bigtext.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.