I am trying to create PHP variables for a user’s innerWidth and innerHeight when they access my page. The goal is to have my graphics and DIVs tailored to their viewport. I have set up a javascript that gets this info and sends it to a PHP file to save them as SESSION vars. Problem is that it only works once I access the site and refresh my screen. And even then it won’t fire if I resize.
I am loading the JS in my HTML HEAD and using
to call the specific function.
I understand that PHP runs before anything else but there must be a way of firing the onload prior to displaying the php.
I think this is a bug in firefox…
Did you test your code on other browsers?
Yes. Tried IE 11, Google Chrome 35, and of course Firefox 29. All require to manually reload the page before the SESSION variables will set
Try doing something similar to this, in you javascript “My Function”
I have a feeling that the resize event is firing and your code just isn’t setting the session variable