Git Product home page Git Product logo

maintainscroll.jquery.js's Introduction

maintainscroll.js

Maintain & keep scroll position after post-back & postback & refresh.

Just include the js file wherever on the page; typically in the head as <script src="maintainscroll.js"></script>. If you want to keep scroll position across multiple pages, include the file on all the target pages.

No need for cookies; leverages window.name to pass the scroll values across the page transition.

maintainscroll.jquery.js's People

Contributors

evaldsurtans avatar hideya avatar

Stargazers

 avatar O0oo0O avatar Amin Esmaeily avatar  avatar  avatar  avatar Tobias Tobak avatar Rebecca avatar Robin Steiner avatar Daniel Oliveira avatar David Achemanaa avatar Jon Tingvold avatar  avatar ChenYuan avatar  avatar  avatar Llewellyn Pritchard avatar N37R09U3 avatar Jay H avatar Arthur Samarcos avatar Rudy Affandi avatar Peterberwind avatar  avatar Donny Kurnia avatar  avatar  avatar Nick Hotalling avatar Kieran Startup avatar David Condrey avatar Amit Yadav avatar Morten Kristoffer Hansen avatar Kyriakos Paschalidis avatar Goran avatar Marcel Wiessler avatar Jędrzej Chałubek avatar Sergey Anuchin avatar Milan T avatar  avatar

Watchers

James Cloos avatar  avatar  avatar  avatar Matt Irwin avatar  avatar

maintainscroll.jquery.js's Issues

chrome issue

in firefox and ie11 worked fine but in chrome given some flashes of page load for set the scroll position of previous any solution for avoid these flashes

Chrome issue

I am just kicking tyres and noticed the following on Chrome (latest Mac)

What happens
I'm on Page A and 500px down the page.
It's this position on Page A to which I wish to return.
However, when I click into Page B from Page A, I end up 500px down the page by default.

Possible improvements: behavioral improvement and un-jquery-fication

Thanks for the nice utility! With my appreciation, here are possible improvement ideas, FYI:

  • Use of window.addEventListener('pagehide', ... ) instead of window.onbeforeunload =
    Use of beforeunload event "prevents browsers from using in-memory page navigation caches", whreas pagehide doesn't and its timing works fine for the purpose.
    Also, usage of window.addEventListener() is safer than directly assigning the handler.
  • By using '[' (no leading space) instead of ' [' in Line 10, and change Line 14 to if(window.name.indexOf('[') >= 0) you can get rid of the use of $.trim() in Line 17, which makes the code a bit simpler.
  • By using window.pageXOffset, window.pageYOffset in Line 10 together with the above, I think it is ready for un-jquery-fication.

Hope this helps!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.