我怎样才能加载PhoneGap的web视图内的网页? [英] How can I load a webpage inside the phonegap webview?

查看:181
本文介绍了我怎样才能加载PhoneGap的web视图内的网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够链接到PhoneGap的web视图加载相同的PhoneGap的WebView内外部网页内的网页。如果我这样做,它加载的WebView里面:

I want to be able to link to a webpage inside the phonegap webview that loads an external webpage inside the same phonegap webview. If I do this, it loads inside the webview:

public class App extends DroidGap {
   @Override
   public void onCreate (Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      super.loadUrl("http://google.com");
   }
}

不过,我想必须先展开内部网页,一个链接到外部网页,所以我这样做:

However, I want to have an internal page launched first, with a link to the external page, so I do this:

public class App extends DroidGap {
   @Override
   public void onCreate (Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      super.loadUrl("file:///android_asset/www/index.html");
   }
}

和我有一个链接:

<a href="#" onclick="navigator.app.loadUrl('http://google.com')">Google</a>

但这个链接将启动,而不是在PhoneGap的web视图谷歌的应用程序之外,在Web浏览器。我能做些什么,以确保链接到外部网页应用程序的PhoneGap的web视图里推出?

but this link launches google outside the app, in the web browser, instead of in the phonegap webview. What can I do to make sure the link to the external page is launched inside the app's phonegap webview?

推荐答案

唉唉......发现在<一个答案href="http://stackoverflow.com/questions/5911255/phonegap-for-iphone-problem-loading-external-url/7768575#7768575">this问题。 我不得不添加

Ahhh.. Found the answer on this question. I had to add

<access origin="www.google.com"/>

phonegap.xml 文件。

这篇关于我怎样才能加载PhoneGap的web视图内的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆