Jquery determines the method by which messages will pop up when the browser returns. jquery returns

Source: Internet
Author: User

Jquery determines the method by which messages will pop up when the browser returns. jquery returns

There must be some messages when the browser returns. Here, jquery is used to determine whether the browser returns and a message is displayed.

JQuery (document ). ready (function ($) {if (window. history & window. history. pushState) {$ (window ). on ('popstate', function () {var hashLocation = location. hash; var hashSplit = hashLocation. split ("#! /"); Var hashName = hashSplit [1]; if (hashName! = '') {Var hash = window. location. hash; if (hash = '') {alert (" Back button isn' t supported. you are leaving this application on next clicking the back button ") ;}}); window. history. pushState ('forward ', null ,'. /# forward ');}});


How to Use JS or JQUERY to determine the return operation of the browser

Is there a return operation for the browser? You can use history. forward (); history. back (); to control the browser's forward and backward functions.

How does jquery or js obtain the browser's back events?

Yes, it cannot be obtained. You can only know that the unload event, the back or forward event are not triggered, but only the onunload Event is triggered.

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.