Access external URL(Google.com) from PhoneGap(Android)

前端 未结 3 536
一向
一向 2021-01-14 20:32

I am new to PhoneGap and Android.I am unable to access Extrenal URL\' like google from PhoneGap,i tried Iframe and Window.Location.Href but not sure why it\'s not working.

相关标签:
3条回答
  • 2021-01-14 20:38

    Have you added the external URLs to the whitelist? There is a file in /res/xml in your project called PhoneGap.xml

    Here is an example of one of my PhoneGap.xml files:

    <?xml version="1.0" encoding="utf-8"?>
    <phonegap>
        <access origin="http://127.0.0.1*"/>
        <access origin="http://devgeeks.org"/>
        <access origin="http://*.phonegap.com"/>
        <log level="DEBUG"/>
    </phonegap>
    
    0 讨论(0)
  • 2021-01-14 20:48

    The access xml helped me. You can use the navigator.app.loadUrl function to get the url loaded in the current webview - look in the cordova.js file for details of the options

    0 讨论(0)
  • 2021-01-14 20:50

    Opening an external link in phonegap / android is only possible two ways: Source: https://build.phonegap.com/blog/access-tags

    check blogpost of phonegap. They're explaining what the android default is, and what you can do about it.

    Follow the discussing on the phonegap forum: http://community.phonegap.com/nitobi/topics/make_links_use_external_broswer_consistently

    Edit:

    1. Add the following code to your config.xml.

       <access origin="http://www.domain.com" browserOnly="true" />
      
    2. Add:

       function loadURL(url){ 
          navigator.app.loadUrl(url, { openExternal:true }); 
       } 
      
    3. Add:

       <a onclick="loadURL('http://www.domain.com')" href="#">Url</a>
      
    0 讨论(0)
提交回复
热议问题