【问题标题】:External URL in PhonegapPhonegap 中的外部 URL
【发布时间】:2012-11-13 11:02:00
【问题描述】:

我想在 Phonegap Android 中打开一个链接,例如 www.google.com...我尝试了很多方法,但无法打开任何链接。

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

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

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

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

谁能解释一下如何在 Phonegap 中打开链接。

【问题讨论】:

  • 您想将该页面加载为应用内的受信任页面,还是将其加载到网络浏览器中?

标签: android url cordova hyperlink phonegap-plugins


【解决方案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');

    });
});

【讨论】:

    【解决方案2】:

    试试

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-12
      相关资源
      最近更新 更多