How to open a web page inside an iOS app with phonegap?

前端 未结 2 2010
后悔当初
后悔当初 2020-12-28 11:36

I want to have only one view in my iOS phonegap app.

This view will be a web page.

How can i load this only view with a specific url?

I suppose you d

相关标签:
2条回答
  • 2020-12-28 12:25

    d0nparalias,

    1. If you want to load main(Cordova's) index.html from remote server, edit config.xml file and change

      <content src="index.html" />

      to

      <content src="http://192.168.1.4:8080/www/index.html" />

      for example. And it will load index.html from web server located on 192.168.1.4.

    2. If you want to open a website right after loading your app, you can use InAppBrowser as you have already noticed.

      window.open(url, target, options);

      Here you have options for target (according to Cordova docs 2.5.0):

      2.1. _self and you'll get something like
      enter image description here
      Note, that you don't have any controls to return to your index.html in this case.

      2.2. _blank — presents modal view controller with dismiss button
      enter image description here

      2.3. _system — opens in Safari.app
      enter image description here

    For more information visit documentation and wiki.

    Hope it helps.

    BR.
    Eugene

    0 讨论(0)
  • 2020-12-28 12:28

    PhoneGap which is now called Apache Cordova on iOS will only let you use a file URL by default. This means you have to load a local .html file. If you want to open a remote page with an http:// URL, you'll need to add custom native code to tell the WebView to load a remote URL.

    0 讨论(0)
提交回复
热议问题