Javascript Calculation Sometimes Not Happening
In the following code snippet: var scr_h = $(document).height(); var scr_w = $(document).width(); var logo = { widt
Solution 1:
I guess it depends on when the code executes with respect to the page being rendered, which is indeterminate if the code is wrapped in $(function(){...}) or similar.
You could try measuring the window rather than the document:
var scr_h = $(window).height();
var scr_w = $(window).width();
Solution 2:
Chchrist answered this question last night in the comments. Setting the calculation to occur after the onload event of the image fixed the problem.
I'm posting this for now, but would love to give credit where it's due!
Post a Comment for "Javascript Calculation Sometimes Not Happening"