move.js
move.js copied to clipboard
document.body.style called before body exists
Uncaught TypeError: Cannot read property 'style' of null
... Move is initialized before body exists. There are workarounds... non of which should be necessary.
Line 284 var styl = document.body.style;
thanks for reporting,
yeah in general you should use defer until the body exists, you can either include the script after the body is loaded or body.onload
or something.
examples should be fixed by me but i'm super lazy :P
I still get this error, how come the issue is closed?
Hi there,
I still get this error : "Uncaught TypeError: Cannot read property 'style' of null " at the exact same line specified above. Is there any fix ?
Thanks, Loris1634
@hems @Loris1634
can you guys come up with a tiny html file that reproduces it ?
Yep. Here it is : http://pastebin.com/2UYcwjsB
I was not really accurate earlier. Here is the exact error I get : TypeError: document.body is null move.js:284 (I am using Firefox)
To solve this error, just put move.js before </body>
:) Works like a charm!
@felquis some people don't include the js on the html source..
Hey, we just encountered this bug in the nastiest of ways: Our module is loaded in the head but MoveJS is only invoked later on runtime.
This resulted in a race condition where we would function normally most of the time, but if we loaded faster than the dom we would get this error.
We would like to issue a pull request to at least workaround this issue. Perhaps an optional flag to skip to document.body.style check.
What do you think?
I have same issue. :(