How to control the mobile browser return to where you want to go

Source: Internet
Author: User

Here I'm going to start with the wrong idea I just started:

I just started thinking I just had to monitor the browser's return event.

Window.removeeventlistener ("Popstate", () ={    false)    

I think wrong pull!

Because in the browser as long as the trigger return event will occur back to the previous browser history, there is no way I am desperate!

I've been searching the internet for a while, so just add a browser history to him.

function  () {  = "#";   = {    "title",    "#"  };  " Title "," # ");}

Run this function and then run the listener event to control the return key

But there's a pit here, because listening events don't run once, so be sure to destroy them manually.

Window.removeeventlistener ("Popstate", () =false)

  Attention! Attention! The above are the wrong ideas don't want to see over

The right idea is this.

Because Window.history.pushState () can add browser history to the browser

That's two more bars to pull.

What consciousness, on the code

Window.history.pushState (null, "", "#/tieoncardpage")//This is the page you want to return Window.history.pushState (  Null, "", "#/setpasswordpage")//This is this page

Ok! Complete

  

How to control the mobile browser return to where you want to go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.