Phonegap 构建 - 在 web 视图中打开外部 link

Phonegap Build - open external link in webview

我使用

在我的应用程序中加载了一个网页
window.location.href="http://www.webpage.com";

现在我想在浏览器中打开一个 link,但是由于我在 webview 中,我的 phone 忽略了 window.open('http://webpage.com', '_system', 'location=yes'); 并在 webview 中打开了 link。 ..

我该如何解决这个问题(使用 PhoneGap Build)?

The funny thing is, "_blank" works when using ajax, but in my case the output is not accurate as when using webview - I need a solution with webview and to over ride it.

我的config.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        id          = "com.me.me"
        versionCode = "10" 
        version     = "1.0.0" >                  <icon src="icon.png" />

<icon src="icon-60@3x.png" gap:platform="ios" width="180" height="180" />



        <name>App</name>

<gap:plugin name="cordova-plugin-inappbrowser" source="npm" version="1.0.0" />


<access origin="*" />

<preference name="EnableViewportScale" value="true"/>
<preference name="orientation" value="portrait" />
<preference name="fullscreen" value="true" />



<preference name="DisallowOverscroll" value="true"/>



</widget>

@Atartica,
根据您上次的回复,我认为您想使用 InAppBroswer。

首先,这是基于使用 Phonegap Build,而不是 Cordova。有区别。

请注意,在大多数情况下,这将按预期工作。但是如果你没有为你的编译器设置版本,你将获得最新版本并且你将被要求使用 white-listplugin,以及 CSP.

这是详细信息 – Current Tripping Points to Cordova/Phonegap,请参阅项目 2。未设置编译器版本.

@Atartica,
好的。谢谢。现在您已经安装了 InAppBrowser,需要安装其余部分。

  • #1 你需要设置编译器的版本,否则你以后会遇到类似的问题。
  • #2 您将需要了解更多有关 Cordova/Phonegap. 的信息,此时,您是在暗中摸索。 FWIW,我没有为此得到报酬。这意味着如果有人对你不满意,那是因为你表现得没有在听。

以下是您需要了解的内容 -- 祝您好运,如有需要,请提出更多问题。


1。尚不支持 iOS9!

PhoneGap 构建 iOS 9 支持状态

  • 2015 年 9 月 23 日

  • http://community.phonegap.com/nitobi/topics/phonegap-build-ios-9-support-status

  • 顶行:iOS 9 NOT 正式支持直到 Cordova-iOS 4.0.0,Cordova 团队是努力工作。然而,一些问题可以通过一些简单的配置更改来解决。

    无论您使用什么,正如论坛 post 所述,直到 Cordova-iOS 4.0.0 才正式支持 iOS 9。这意味着,如果您遇到错误,您必须 - 创建一个解决方法,或者等到它得到正式支持, 向 cordova 提交错误报告, 等到其他人创建解决方法。

    至于何时支持 iOS9,我*个人*猜测是很快。不超过30天。对此有很多抱怨。 Cordova 团队正在聆听。

2。未设置编译器版本

来自 Phonegap Build 论坛,Petra Adds

I would add: without announcement, PGB changed the default PGB-version from 3.7.0 to cli-5.2.0. This causes all those who have not set 'phonegap-version' in config.xml to be confronted with the sudden need of splashscreen and whitelist plugins and additional whitelisting specifications in config and html.

Also, several plugins seem not to build correctly with cli-5.2.0, causing log file error messages about "Class ***.java".

FWIW:Phonegap 版本 admitted to as much in this tweet

Top Mistakes by Developers new to Cordova/Phonegap 你已经命中:

  • #6 没有为您的编译器设置“phonegap 版本”
  • #7 没有为你的插件设置“版本”
  • #10 未在 config.xml 中添加新的“白名单”和“白名单插件”参数。

#6 和#7

With the CLI version, if you do not assign a version for your platform OR in ''Phonegap Build'' if you do not set the phonegap-version in config.xml, YOU WILL GET THE LATEST VERSION. If you are lucky, your program just works as expected. If you are not lucky, you'll get a set of cascading error.

Luckily for all of us, Holly Schinsky has written a nice blog post to explain it all:

Cordova/PhoneGap Version Confusion
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

对于#10

This relatively * NEW * requirement means – to access ANY website or resources on the web, you MUST use the whitelist and the whitelist plugin. This requirement goes into affect, if you are using cordova-android@4.0.0 or better; including cli-5.1.1. If however, your version is before 4.0.0, let use say 3.5.0 or 3.7.0, then you will not have to add the white-list requirement.

To be clear, the "whitelist" has been around for a bit, but the plugin and requirement is very new. As you would expect, when the "whitelist" was added, the defacto open-access feature was deprecated. Or said another way, the defacto open-access feature was planned and scheduled to be eliminated. This change marks a step in removal of the open-access feature.

In addition, the Content Security Policy (CSP) has caught numerous developers - because it was soooo poorly publicized. This CSP needs to go in every single HTML page you used, just like you have to wait for 'deviceready'. The documentation is buried in the bottom of many of the latest documentation pages.

相关链接

Phonegap Build Forum: Notes for upgrading to cli-5.1.1 on PGB and now required Whitelist