Phonegap web app in regular desktop browsers

前端 未结 18 1725
深忆病人
深忆病人 2020-12-08 02:27

If I develop a web app in phonegap, can the same web app be made to run in regular desktops/laptops inside a browser?

相关标签:
18条回答
  • 2020-12-08 02:49

    It will definitely run on desktop, IF you do it in right way.

    I do this with many of my apps,But it`s good to wrap your device specific event listeners like:

    onDeviceReady: function()  {
    
          // Your Code  for Device event listner
    
        },false);
    

    And initialize the function

    document.addEventListener("deviceready", onDeviceReady, false);
    
    0 讨论(0)
  • 2020-12-08 02:51

    if you use a mac, open terminal and disable web security

    open -a /Applications/Google\ Chrome.app --args --allow-file-access-from-files --disable-web-security
    

    open your homepage.html and ENJOY :)

    0 讨论(0)
  • 2020-12-08 02:53

    Check out the Ripple Chrome plugin to run PhoneGap apps along with device-type emulation in the Chrome browser.

    0 讨论(0)
  • 2020-12-08 02:54

    Not in browser but Phonegap have Windows 8 support so if you compile your application as here

    ; you can run your application just on w8 but i didn't try that.

    0 讨论(0)
  • 2020-12-08 02:54

    You can install an Android VM and run it on your desktops/Macs/Cisco office terminals/phones/etc. What you are probably asking is if you can have a single code base. The answer is 99% yes. You need a few "extra" files for phonegap (index.html, config) but other than that you can deploy the same code to both places. It works fine. Well, there are "gotchas" such as <input type="number"> not working right on some phones/tablets and datalist not being supported in current Android version and a bunch of others. Also issues with layout which you can address somewhat with media-query. But, yet, same code base in both places. Just do AJAX to webservices and its all good. HTML lives locally within your app, if you want.

    The PhoneGap app is 99% identical to the WebApp. In fact, the exact same folder is zipped and uploaded to build.phonegap as is copied to the web portal. Exactly as stated above, you can use the same web app and it DOES run in a web browser. BTW, you can use the camera from HTML/js and DO NOT need PhoneGap-specific code. Same for GPS (though you'll need some robust code to make it work on many of the phones). Accelerometer and other hardware would of course be exceptions; but, duh!

    In fact, my answer is one of only two which points out lots of the issues you'll hit. Also, need to point out the mess of device pixels. You can finesse with CSS and percentage layout and then use media-query to add custom CSS mods for tablet, newer phones, etc. It becomes a mess of course. You end up making nearly custom screens for tablet, phone, and other display sizes if you want even better support. Then you learn to make UI widgets/fragments/whatever and make them smart. A simple example is using jquery datatable and changing the columns when on smaller devices (hide lower information content columns). Etc. Change radio buttons to selects and such on smaller phones. And so on. Of course, you'll end up having to invent your own droplist or using one from jquery UI etc since the Android tablet implementation of html select blows.

    0 讨论(0)
  • 2020-12-08 02:55

    DesktopGap use embedded Chrome browser instead of IE. There is only Windows version.

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