Page reload even using scroll

Hi everybody.

I am working with the following script to reload the page if resizing.

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

Works fine, but I have found that in some browsers it refreshes the page even when you use the scroll.

Is there any other option or a way to fix this.


That shouldn’t happen. Which browsers are exhibiting this behaviour?

Browsers in Samsung.

Don’t follow. On a Samsung device?

Yes. I have tested in two different Galaxy. And it seems that the problem is the same in Iphone.

I have been looking for information on the issue and get some answers from people talking about stopping propagation onscroll.

I think they are right.

Ok, well do that then, I guess. Did you at least try it?

I am working on it.

Do you know why this does not work?

 window.onscroll = function(){ stopPropagation(); };

Yes. It needs to be called on an event object.

 window.onscroll = function(e){ e.stopPropagation(); };

But on its own, this code is meaningless.

What are you trying to do? This all seems somewhat strange.

Applying a stoppropagation function to the onscroll event.

But that’s like saying “on scroll, do nothing”

1 Like

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

window.onscroll = function(e){ e.stopPropagation( location.reload() ); };


Are you sure? Do you have an example?

That doesn’t make sense and doesn’t happen on my iphone.

Why are you reloading the page on resize anyway as that seems a little strange and annoying for your users?

It does not matter why. It is a problem of elements in higher or lower resolutions. Forget. I need the page to refresh when resizing.

I have tested on three phones and it happens. When I scroll down, the page refreshes.

Can you set up a small demo and then we can test on our phones to see if we get the same result?

Nothing happens when you scroll on my iphone with this most basic of demos but I may be missing the point:)

I cannot, because it includes a login. You need to login to the page, because the .js file loads only for users.

Yes you are right that it does not matter to the problem in hand as such and that needs to be solved but I was just wondering if perhaps you were addressing a css problem in the wrong way?

I often see people using js to tackle css problems when they don’t need to so it’s often the first question I ask :slight_smile:

I’ll hand you back to @James_Hibbard as he may have heard of problems with resize and scroll. I was just trying to come at the problem from a different angle.:wink:

Sorry, Paul, but without a runnable example that demonstrates the problem and an open mind towards discuss best practices, andresb is making it quite difficult for us to help him.

There’s a discussion of something similar here:

Maybe that’ll help?

1 Like

stopPropagation() doesn’t take any arguments; now in JS this doesn’t matter as additional arguments will simply go nowhere, but they will still get evaluated, so what you’re effectively doing is calling location.reload() there.

As for the sample page, you might set up a basic page that just demonstrates that behaviour – if not for us, reproducing it might help you to pin the problem down.

That said, I concur with @PaulOB… reloading the page on resize just doesn’t seem right, and there is likely a much less obtrusive solution to your problem.

1 Like