phonegap: open external page and then go back to app

前端 未结 3 901
感情败类
感情败类 2021-02-09 11:25

ok, browsing the questions I\'ve found the right way to load an external page into the phonegap view (i.e. without loosing the session or opening the device browser) as explaine

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-09 11:56

    You want to use the ChildBrowser plugin to open the external web page. Then you want to set the ChildBrowser.onLocationChange property to your own function. Then when the person navigates away from the remote page you will be notified of the location change so you can then close the ChildBrowser and navigate to a new local page. You won't even need to touch the remote html page.

    So to close the browser when the user navigates away from the remote page:

    cb.onLocationChange = function(loc){
        console.log("location = " + loc);
        if (loc != "http://example.com") {
            cb.close();
        }
    }; 
    

提交回复
热议问题