我正在尝试在“可关闭的”InAppBrowser中打开Phonegap应用程序中的链接,或者至少在外部Safari出现时,而不是在Webview本身内。
使用_blank或_system总是会产生'_self'beahviour(页面在Webview中打开)。
我正在尝试一个全新的Phonegap项目,针对iOs。模拟器和设备上的问题相同。
正确安装InAppBrowser:
$ cordova plugins ls
[ 'org.apache.cordova.inappbrowser' ]
project.xml没什么好看的:
<?xml version='1.0' encoding='utf-8'?>
<widget id="me.nerik.superpo" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">
<name>Test</name>
<description>
Hello World sample application that responds to the deviceready event.
</description>
<author email="support@phonegap.com" href="http://phonegap.com">
PhoneGap Team
</author>
<feature name="http://api.phonegap.com/1.0/device" />
<preference name="permissions" value="none" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="true" />
<preference name="webviewbounce" value="true" />
<preference name="prerendered-icon" value="true" />
<preference name="stay-in-webview" value="false" />
<preference name="ios-statusbarstyle" value="black-opaque" />
<preference name="detect-data-types" value="true" />
<preference name="exit-on-suspend" value="true" />
<preference name="show-splash-screen-spinner" value="true" />
<preference name="auto-hide-splash-screen" value="true" />
<preference name="disable-cursor" value="false" />
<icon src="icon.png" />
<icon gap:platform="ios" height="57" src="res/icon/ios/icon-57.png" width="57" />
<icon gap:platform="ios" height="72" src="res/icon/ios/icon-72.png" width="72" />
<icon gap:platform="ios" height="114" src="res/icon/ios/icon-57-2x.png" width="114" />
<icon gap:platform="ios" height="144" src="res/icon/ios/icon-72-2x.png" width="144" />
<gap:splash gap:platform="ios" height="480" src="res/screen/ios/screen-iphone-portrait.png" width="320" />
<gap:splash gap:platform="ios" height="960" src="res/screen/ios/screen-iphone-portrait-2x.png" width="640" />
<gap:splash gap:platform="ios" height="1024" src="res/screen/ios/screen-ipad-portrait.png" width="768" />
<gap:splash gap:platform="ios" height="768" src="res/screen/ios/screen-ipad-landscape.png" width="1024" />
<access origin="*" />
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
</feature>
</widget>
这是javascript:
var app = {
// Application Constructor
initialize: function() {
document.querySelector("h1").onclick = function()
{
console.log("clicked !");
// var ref = window.open( "http://google.com", '_blank', 'location=yes');
var ref = window.open( "http://nerik.me", '_system');
};
}
};
答案 0 :(得分:1)
碰巧我没有等待'deviceready'开火。 在某些时候,我(愚蠢地)评论了等待应用程序启动事件的部分,因为'deviceready'不再被激活。 我不得不用cordova.js替换phonegap.js。我不确切地知道为什么:(