I need to build an offline Phonegap app. However, all of my js functions need a web server to run well. Is it possible to embed a local web server into phpnegap project?
相关问题
- Should I use CSS3 media queries to deliver differe
- apk big size with ionic 4 build
- how to Enumerate local fonts in silverlight 4
- How to read file in android using PhoneGap Javascr
- Ionic start give error: There was an error with th
相关文章
- embed 循环播放MP3文件(loop="2"变成无限循环)
- Could I create “Call” button in HTML 5 IPhone appl
- Phonegap - Error - Keystore alias not recognized
- Can't use serve with Cordova / Phonegap hellow
- How to dynamically add wmode=transparent to Youtub
- ionic - Copy/paste in input field in iOS 10 not wo
- PhoneGap iOS 7 and localStorage
- deviceready not firing in cordova
Now it is possible, I created a plugin what meets your requirements.
First install it via:
Then just describe your Webserver in the start of your application
after that you can access your webserver on another browser in your network:
http://<ip-of-webserver-device-in-local-network>:8080
Reference: https://github.com/bykof/cordova-plugin-webserver
Yes, it's possible using a Cordova HTTPD plugin:
https://github.com/floatinghotpot/cordova-httpd
I haven't used it yet, but I may need to with my current project.
One drawback is that if the IP address is known, others will be able to browse the hosted files. Before I deploy, I'll be changing that behavior.
An embedded webserver is possible, and in the (distant) past, Cordova Android even had one.
However, for the general use case it should not be needed. If you must serve files from a local server, see Michaels answer.
loadUrl through the native webview api is NOT the (best) to include javascript in the webview's runtime.
By default, there is no reason why you need to interact natively with the webview in the first place.
Instead, create an index.html and include the javascript you want through tags, as @frank describes
The cordovawebview.loadURL will by default load index.html, and does not need to be modified.
look at the www/index.html in the Cordova Hello World App for a simple example.
--edit-- link to index.html in CDV Hello World