1

I think I found the answer I am looking for here: Refreshing page automatically when viewport size change but I do not know how or where to put this:

window.onresize = function(event)
{
document.location.reload(true);
}

I am trying to accomplish the same thing as the OP where I need to force a refresh on screen rotate.

Any help is appreciated.

EDIT:

The script is not working or so it seems. When I rotate my tablet (android) the responsive images do not resize which they should if the browser is being refreshed. This leads me to believe it is not working.

EDIT 2:

My error, forgot to re-upload the changed file. It has been a long day and I just noticed that Filezilla still had the change file prompt on the screen! This is now working for me.

EDIT 3: NEW PROBLEM

Now that it is working, I noticed that when I scroll the page it forces a refresh again with every movement (scrolling down, not up) even though the viewport has not rotated. Why is this and is there a way to fix it? It appears not to affect my iPhone 4, only my Samsung tablet...

ADDED:

I figured out that it is when the browser tabs move off the viewable area of the page that it forces a refresh on the tablet. Is there a way to change this?

UPDATED: Appears to be a Chrome issue again.

Community
  • 1
  • 1
Leah
  • 331
  • 4
  • 17
  • You should *never* need to do this... Try resizing your browser window and see what happens. – Niet the Dark Absol Mar 08 '14 at 21:56
  • @NiettheDarkAbsol I have resized the browser, this is why I am asking. The slideshow images (on the home page) for some reason do not resize until the page is refreshed. website is: kspalding.wpengine.com – Leah Mar 08 '14 at 21:58

1 Answers1

1

Doesn't really matter where you put it on the page as long as it's in a <script> tag. You could put it at the top of your page in the <head> if you want.

<head>
   <script language="javascript">
       window.onresize = function(event) {
          document.location.reload(true);
   } 
   </script>
</head>
Rick S
  • 6,476
  • 5
  • 29
  • 43
  • Doesn't seem to be working on my tablet when I switch from portrait to landscape? Is there something I am missing? Website in question is kspalding.wpengine.com – Leah Mar 08 '14 at 21:46
  • The reason for the refresh is that the images in the slideshow are responsive and when the screen rotates the images don't resize themselves until the page is refreshed. – Leah Mar 08 '14 at 21:52