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

I am new to PhoneGap and Android. I canโ€™t access Extrenal URL 'like google from PhoneGap, I tried to use iframe and Window.Location.Href but I donโ€™t know why it doesnโ€™t work.

<!DOCTYPE HTML>
<html>
<head>
<title>PhoneGap</title>
<script type="text/javascript" charset="utf-8" src="phonegap-0.9.3.js"></script>


<link rel="stylesheet" href="jquery.mobile-1.0a1.min.css" /> 
<script src="jquery-1.4.3.min.js"></script> 
<script src="jquery.mobile-1.0a1.min.js"></script>

</head>
<body>
<iframe src="http://www.google.com"></iframe> 
</body>
</html>
+2
source share
3 answers

Have you added external URLs to the whitelist? There /res/xmlis a file in your projectPhoneGap.xml

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

<?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>
+10
source

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

Check out the blog post of a telephone conversation. They explain what android is by default, and what you can do about it.

phonegap: http://community.phonegap.com/nitobi/topics/make_links_use_external_broswer_consistently

Edit:

  • config.xml.

     <access origin="http://www.domain.com" browserOnly="true" />
    
  •  function loadURL(url){ 
        navigator.app.loadUrl(url, { openExternal:true }); 
     } 
    
  •  <a onclick="loadURL('http://www.domain.com')" href="#">Url</a>
    
+6

Xml access helped me. You can use the function navigator.app.loadUrlto get the url loaded in the current web view - look in the file for cordova.jsdetailed information about the parameters

+1
source

All Articles