apiCloud app調用瀏覽器打開網頁的方法


在APP調用瀏覽器有兩種方法:
1.使用openApp
2.使用openWin

兩種方法調用瀏覽器后的效果有一點不同:
1.使用openApp調用瀏覽器后,如果手機內有多個瀏覽器,會首先彈出選擇瀏覽器的框
2.使用openWin,直接打開網頁,但是不顯示地址欄(不能輸入url)

安卓平台測試代碼:
兩個按鈕:

<input type="button" onclick="openApp()" value="openApp"/>
<input type="button" onclick="openWin()" value="openWin"/>

js代碼:

               function openWin() {
                        api.openWin({
                                name : 'win_show2',
                                url : 'http://www.baidu.com',
                                rect : {
                                        x : 0,
                                        y : 0,
                                }
                        })
                }

                function openApp() {
                        api.openApp({
                                androidPkg : 'android.intent.action.VIEW',
                                mimeType : 'text/html',
                                uri : 'http://www.baidu.com'
                        }, function(ret, err) {
                                var msg = JSON.stringify(ret);
                                api.alert({
                                        title : 'openApp',
                                        msg : msg,
                                        buttons : ['確定']
                                });
                        });
                }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM