Reloading the website on resolution change

The code I posted on this link¬†works fine, but has one limitation – if the site visitor changes the resolution (rotates the mobile phone or tablet device), the stacking will remain as it was in the first place. And this translates into layout errors. Hence the client requested for a way to avoid this – one of the ideas is to reload the website on resolution (orientation) change. Here’s the snippet that worked for me: