Load external page on to Cordova/Phonegap application

前端 未结 2 618
情话喂你
情话喂你 2021-02-04 21:42

I have a Cordova/Phonegap application. that on start checks the internet connection. Actually the app executes local files, but I would, that when there is internet connection,

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-04 22:23

    You can Load an external page to the app using Jquery load() or by Ajax or by InApp browser.

    If you want to show the external page to a div, you can do it by load() or by ajax call

    HTML:


    JS:

    /*Using Jquery Load()*/
    $('#Load').load('http://www.google.co.in');
    
    /*Using ajax*/
    $.ajax({
      dataType:'html',
      url:'http://www.google.co.in',
      success:function(data) {
        $('#ajax').html($(data).children());   
      }
    });
    

    OR by Inapp browser

     window.open('http://www.google.co.in','_self');
    

    go through the documentation

    Before using inappbrowser you must install the plugin to your project To add inappbrowser to project by commanline

    $ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git
    

    Hope this will helps you.

提交回复
热议问题