Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll To Top On Page Load (HTML)

I have tried both onload="window.scrollTo(0,0);" and onload="$('html,body').scrollTop(0);" but after the page loads it still stays at the current position, I am using frames. I have tried some of the other suggestions but still no luck could someone please point me in the right direction. Do I need to add a scroll to top to my frame? I need the page that contains the frame to reload when the frame inside reloads, hope it makes sense.

<body onload="window.scrollTo(0,0); $('html,body').scrollTop(0);"> <iframe id="my-iframe-tag" scrolling="no"> </iframe> </body>

like image 461
Marius Brits Avatar asked Nov 26 '25 10:11

Marius Brits


2 Answers

hi all this seems to have done the trick onload="parent.scrollTo(0,0);" after some searching this helped Scroll to top of parent frame on iframe change? thanks though

like image 155
Marius Brits Avatar answered Nov 28 '25 02:11

Marius Brits


Using the scrollTop method on DOM ready:

$(document).ready(function(){
    $(this).scrollTop(0);
});
like image 28
Daniel J Abraham Avatar answered Nov 28 '25 01:11

Daniel J Abraham



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!