In front-end time, our company has made a product that uses Baidu Wallet’s mobile web payment. Users scan the QR code of our
product through Baidu Wallet and Baidu Nuomi, select the product, and click to pay. Baidu Wallet will be automatically called for payment. After the payment is successful, the success page will be returned. There is a close
button on our success page. Clicking the close button or the return button will close the page.
Using the BLightApp.closeWindow() method of Baidu Light App in Baidu Wallet can be closed, but in Baidu Nuomi, it can be used logically,
But it doesn’t work at all, so change it to traditional Neither does window.close(). At that time, we searched online and found no solution on Baidu Nuomi’s official website. Later,
found a solution after many twists and turns and contacted Baidu Nuomi’s related technologies.
The solution is very simple, just set the jump address to bainuo://home.
First method: Click the button to close the page
Click the button to close the page
As shown in the figure, click the button, it will To close the page, the code is as follows:
Second: Click the app return button or the phone’s back key to close the page
Click the app return button or the phone’s back key Back key to close the page
As shown in the picture, click the "<" button in the red box or the physical back button on the phone to close the page. The code is as follows:
Introducing jQuery:
Specific implementation code:
$(function(){ pushHistory(); window.addEventListener("popstate", function(e) { pushHistory(); var ua = navigator.userAgent.toLowerCase(); if(ua.match(/MicroMessenger/i)=="micromessenger") { WeixinJSBridge.call('closeWindow'); } else if(ua.indexOf("alipay")!=-1){ AlipayJSBridge.call('closeWebview'); }else if(ua.indexOf("baidu")!=-1){ BLightApp.closeWindow(); }else if(ua.indexOf("bdnuomi")!=-1){ window.location.href="bainuo://home"; } else{ window.close(); } }, false); function pushHistory() { var state = { title: "title", url: "#" }; window.history.pushState(state, "title", "#"); } });
The above is the method of closing web pages or windows in Baidu Nuomi app. 99% of people don’t know it and can’t find it online. Content, for more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!