phonegap应用程序中的外部链接打开不好 [英] External links in phonegap app do not open well

查看:113
本文介绍了phonegap应用程序中的外部链接打开不好的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个Phonegap 2.9.0 Phonegap项目,并建立与PhonegapBuild。

我有我的应用程序中的外部链接,我想打开inapp或使用默认设备浏览器app。我对这两个解决方案确定。今天我的应用程序打开链接inapp,但它去全屏,无法缩放,没有按钮,回来在应用程序...

我试图找出一个解决方案的天,看着同一个这里的问题,但没有什么工作好。



可能有人解释清楚这些东西是什么,以及什么是不同的选择/参数,因为我可以告诉它是不清楚/容易的! p>

Q1:

我首先要问:在文件config.xml中,偏好stay-in-webview现在已弃用于phonegap 2.3.0 ?那么这里没有什么希望?



Q2:
我阅读并尝试了很多关于插件InAppBrowser与window.open和目标系统/空白/差异为我。我留在InApp但没有用,因为没有导航按钮。

我在这里缺少什么?

  plugin name =InAppBrowservalue =CDVInAppBrowser


解决方案


我首先要问:在config.xml文件中的偏好stay-in-webview现在已弃用phonegap 2.3.0对不对?那么这里没有什么希望?


这是正确的。如果你使用的是2.9,不要担心这个设置。


我阅读并尝试了很多关于插件InAppBrowser与window.open和目标系统/ blank / self,但对我没有区别。我留在InApp但无用,因为没有导航按钮。我在这里缺少一些东西吗?


我有几个问题让这个工作。他们的文档有点分散,需要读一切。这是我如何使其工作:


  1. 确保您拥有< script src =phonegap.js> ;

  2. 您不需要在配置中包含插件标记。
  3. xml。我非常确定他们在核心构建功能中包含了inappbrowser。
  4. 要在inappbrowser中打开链接,请使用以下javascript:

      function openURL(urlString){
    myURL = encodeURI(urlString);
    window.open(myURL,'_blank');
    }

    这将打开inappbrowser中传递的URL。如果你改变 window.open(myURL,'_blank'); window.open(myURL,'_system');


  5. 最后,您的项目点击如下所示:

     < a href ='#'onclick ='openURL(http://www.urlyouwant)/> 

    或者你可以附加事件列表到对象,但我想你得到的。 >


此外,InAppBrowser有很多可附加到它的事件监听器。如果您对这些感兴趣,请查看文档



重要!不要忘记第1步!



希望这有帮助。


So I have a phonegap project with Phonegap 2.9.0 and building with PhonegapBuild.
I got external links in my app, that I would like to open inapp or using the default device browser outside of my app. I am ok for both solutions. Today my app open links inapp but it goes fullscreen, no zoom possible, and no button to come back in the app...
I am trying to figure out a solution for days, and looking at the same kind of questions here but nothing work good.

Could somebody explain clearly what is all this stuff about, and what are the different choices/params because I can tell that it is not clear/easy at all!

Q1 :
I would start by asking : in the file config.xml the preference stay-in-webview is deprecated now for phonegap 2.3.0 right? So nothing to hope here?

Q2 : I read and try a lot about the plugin InAppBrowser with window.open and target system / blank / self but no differences for me. I stay InApp but useless because no navigation buttons.
Am I missing something here?

plugin name="InAppBrowser" value="CDVInAppBrowser"

解决方案

I would start by asking : in the file config.xml the preference stay-in-webview is deprecated now for phonegap 2.3.0 right? So nothing to hope here?

That's correct. Dont even worry about this setting if you are using 2.9

I read and try a lot about the plugin InAppBrowser with window.open and target system / blank / self but no differences for me. I stay InApp but useless because no navigation buttons. Am I missing something here?

I had a few issues getting this to work as well. Their documentation is a bit scattered and need to read it all. Here is how I get it working:

  1. Ensure you have <script src="phonegap.js"></script> in each of your pages that wants to use the inappbrowser
  2. You should NOT need to include a plug-in tag in your config.xml. I am pretty sure that around 2.5 they included inappbrowser in the core build functionality.
  3. To open a link in the inappbrowser, use this javascript:

    function openURL(urlString){
        myURL = encodeURI(urlString);
        window.open(myURL, '_blank');
    }
    

    This will open the passed URL in the inappbrowser. If you change window.open(myURL, '_blank'); to window.open(myURL, '_system'); it will open the passed URL in the system browser.

  4. Finally, your item clicks look like this:

    <a href='#' onclick='openURL("http://www.urlyouwant")/>
    

    Or you could attach event listiners to the object, but I think you get the point.

Additionally, the InAppBrowser has a lot of event listeners you can attach to it. Take a look at the documentation if you are interested in those.

Important!!!! Do not forget step 1!

Hope this helps.

这篇关于phonegap应用程序中的外部链接打开不好的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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