Home > Web Front-end > H5 Tutorial > body text

Baidu Wallet iOS mobile html5 web page cannot be automatically closed

黄舟
Release: 2017-02-09 15:42:25
Original
1835 people have browsed it

Our company is currently developing a product for Baidu Wallet’s mobile web payment. The product usage scenario is when the user scans the QR code of our product through Baidu Wallet,

enters our product, and then The user selects the product and clicks to purchase, then generates an order in the background of our system and submits the information to Baidu Wallet for payment. When the payment is

completed, our system page will automatically close. This feature is available on Android phones, but cannot be turned off on iOS.


By contacting the technical support of Baidu Wallet, it turns out that on the iOS side, you need to add the runtimeready event to the document first. When Baidu Wallet’s sdk js is injected successfully

The runtimeready event will be triggered later, so that the relevant action of closing the window can be performed.


The following is the specific code:

var ua = navigator.userAgent.toLowerCase();   
    //判断是否为ios设备,其他设备直接调用 BLightApp.closeWindow()关闭  
    if(ua.indexOf("apple")!=-1||ua.indexOf("mac")!=-1||ua.indexOf("iphone")!=-1)  
        {  
            var event = document.createEvent('Events');  
                event.initEvent('runtimeready', false,false);  
                document.dispatchEvent(event);  
                document.addEventListener("runtimeready", function(e) {  
                     BLightApp.closeWindow();  
                }, false);  
        }else{  
             BLightApp.closeWindow();  
        }
Copy after login

The above is the content of the problem that Baidu Wallet ios mobile html5 webpage cannot automatically close, more related content Please pay attention to the PHP Chinese website (m.sbmmt.com)!


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!