2012-11-13 46 views
0

我想在Phonegap Android中打开www.google.com这样的链接...我尝试了很多东西,但无法打开任何链接。Phonegap中的外部URL

<access origin="http://google.com" />已经添加到config.xml。

navigator.app.loadUrl('http://google.com');给出错误。

$('#pageID').load('http://google.com',function(){ 
$('#pageID').trigger('create'); 
}); 

正在加载页面,但不显示图像,这是我的情况所必需的。

任何人都可以解释如何实际打开Phonegap中的链接。

+0

是否要将页面作为应用程序中的受信任页面加载,或者是否希望将其加载到Web浏览器中? –

回答

1

那么它似乎它不可能.....但我发现,我们可以做到这一点反过来。

我们知道这个工程: -

<a data-role="none" id="someID" href="#" target="_blank"> 

因此,我们可以写的jQuery为: -

$('#idAnchorTag').attr('href','some URL'); 

所以完整的代码是: - (假设点击了图像上进行)

<a data-role="none" id="idAnchorTag" href="#" target="_blank"> 
    <img id="idIMG" src="some IMAGE"> 
    </a> 

而且JS: -

$(function() { 
    $("#idIMG").click(function(){ 

     $('#idAnchorTag').attr('href','some URL'); 

    }); 
}); 
0

尝试

$('#pageID').onClick(function(){ 
    document.location.href="http://google.com"; 
}) 
+0

不,它不工作 –