I ran across this code in some HTML and I am unsure what the point of it is:
onresize="window.location.reload(false);"
I am not very proficient in JavaScript, but it looks like it basically just... reloads the browser window when it is resized? Does that even work? It seems odd.
It does reload the page as you suspect, although the argument false that is passed to reload indicates that the page should be reloaded from the cache if possible, to minimize load time. See Mozilla's window.location documentation for more details.
I suspect this is to force the browser to re-layout the page in case resizing the window changes how it renders. Typically that should not be necessary, especially if the site is employing responsive web design techniques, but some sites may do it anyway.
I agree with Stuart. Do you own this code? In other words can you make changes to the code and deploy it to some test environment? If so, try commenting that line and see what happens. May be this line was added way back when some particular browser couldn't handle window re-size events correctly. May be it's not needed anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With