Home  >  Article  >  Web Front-end  >  99% of people don’t know how to close web pages or windows in Baidu Nuomi app, and they can’t be found online.

99% of people don’t know how to close web pages or windows in Baidu Nuomi app, and they can’t be found online.

黄舟
黄舟Original
2017-02-09 15:48:332421browse

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

99% of people don’t know how to close web pages or windows in Baidu Nuomi app, and they can’t be found online.

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:

<center><a href="bainuo://home" ><button style="width:200px;height:50px;font-size:16px;">点击按钮关闭</button></a></center>

Second: Click the app return button or the phone’s back key to close the page

99% of people don’t know how to close web pages or windows in Baidu Nuomi app, and they can’t be found online.

Click the app return button or the phone’s back key Back key to close the page


As shown in the picture, click the "

Introducing jQuery:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>

Specific implementation code:

$(function(){  
    pushHistory();  
    window.addEventListener("popstate", function(e) {  
        pushHistory();  
        var ua = navigator.userAgent.toLowerCase();    
        if(ua.match(/MicroMessenger/i)=="micromessenger") {    
             WeixinJSBridge.call(&#39;closeWindow&#39;);  
        } else if(ua.indexOf("alipay")!=-1){    
             AlipayJSBridge.call(&#39;closeWebview&#39;);    
        }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 (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn