No. listening public back button to exit directly to the public page number

Direct exit to the public page number

window.history.pushState(null, null, "#");
            window.addEventListener('popstate', function(e) {
                WeixinJSBridge.call('closeWindow');
            }, false);

By listening popstate event to determine whether to click on the back button, for example, to jump from page A to page B (listen popstate),
then jump to C page, click on the back button, the test is successful, including the Android version,
but the question is WeChat IOS version, will immediately contact law popstate events that led to jump directly from C page to a page,
other PayPal (Android, IOS), micro-letter (Andrews) is possible, that is, micro-channel IOS version does not work.

Solution

var isRun = '' 
            var isRuns 
            function isRuns () { 
                isRun = to false 
                //                 exit directly to the public page number 
                window.history.pushState ( null , null , " # " ); 
                window.addEventListener ( ' the popstate ' , function (E) {
                     IF (== isRun to true ) { 
                        WeixinJSBridge.call ( ' closeWindow ' ); 
                    } 
                },to false ); 
            } 
            window.history.pushState ( null , null , " # " ); 
            window.addEventListener ( ' pageshow ' , function () { 
                isRun = to false ; 
                the setTimeout (function () { 
                    isRun = to true ; 
                }, 1000 ); // 1 second delay execution returns immediately to prevent micro-channel popstate event 
                isRuns () 
            });

 

Guess you like

Origin www.cnblogs.com/1212dsa/p/11429279.html