2013-12-19 29 views
4

我試圖在Phonegap應用程序中打開一個「可關閉」InAppBrowser中的鏈接,或者至少在外部Safari中發生,而不是Webview本身。在Cordova/Phonegap 3.3中的外部鏈接/ InAppBrowser總是表現得像「_self」

使用_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="[email protected]" 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'); 
    }; 

} 
}; 
+1

儘管你可能已經找到了一個與你的應用程序init代碼有關的解決方案,但是你的錯誤聽起來很像我報告的一個錯誤,那就是從CLI添加一個插件基本上失敗生成正確的cordova_plugins.js文件https://issues.apache.org/jira/browse/CB-5844?jql=text%20~%20%22inappbrowser%20ios%20cordova_plugins.js%22 – kontur

回答

1

碰巧我沒」等待'deviceready'開火。 在某些時候,我(愚蠢地)評論了等待應用程序啓動事件的部分,因爲'deviceready'不再被觸發。 我不得不用cordova.js替換phonegap.js。我不知道究竟爲什麼:(

+0

您可以標記自己的文件回答爲「正確」,所以這個問題不會再公開。 – kontur