search

Home  >  Q&A  >  body text

javascript - How to return to the original position of the list page from the details page on the mobile terminal?

1. What we are currently doing is to locate the original position when returning from the details page to the list page in the angular mobile terminal.
2. My code is to record the current position on the list page

document.addEventListener('touchstart', function (e) {
    console.log(angular.element(e.target)[0].offsetTop);
    var eleTop = angular.element(e.target)[0].offsetTop;
    localStorage.setItem("top", eleTop);
 }, false);

Return function: But the value printed here is no longer the value originally stored, but the position when clicking return.

function goBack() {
            console.log(localStorage.getItem("top"));            
                history.back();
        }

Please tell me how to locate the value recorded in the list page, or is there any better way?
Thanks!

给我你的怀抱给我你的怀抱2784 days ago979

reply all(1)I'll reply

  • 某草草

    某草草2017-07-05 10:39:41

    Change entering the details page to js trigger, record the current position before jumping, enter the page to verify whether there is this value, if so, let the page stay at this position, and clear this value, if not, skip. The idea is probably this, the code is completed by itself. If you don’t understand that part, you can ask me. If you want the complete code, don’t ask me

    reply
    0
  • Cancelreply