2013-08-22 154 views
1

我遇到問題了!我正在爲iOS和Android開發一個phonegap應用程序。當我打電話Phonegap Android應用程序在外部瀏覽器中打開鏈接後終止

window.open(url, "_system") 

在iOS上它打開了,但我可以導航到我之前在我的應用程序的地方。但是當我在Android中打開鏈接並導航迴應用程序時,它從一開始就開始。 如何讓應用程序保持原樣離開並返回到它之後的方式?

+0

您可能想要考慮重寫'onBackPressed'函數,以便設置您希望後退按鈕離開的頁面。 – g00dy

+0

我有一個類似的問題:當我使用onclick =「javascript:window.open(」http:myurl「,」「,」「)打開一個新窗口時,窗口打開並加載正常,但是當我返回到我的應用程序通過按下後退按鈕,我的整個應用程序重新加載。你是否也使用jQueryMobile爲應用程序的任何機會嗎? – Wytze

回答

1

的Andorid

function openInApp(link){ 
      console.log("Open Call"+ link); 
      if(link.length<=1){ 

        navigator.notification.alert(
             'Page not found..!', // message 
             null,   // callback 
             'Title', // title 
             'Ok'     // buttonName 
            ); 

      }else{ 
      var ref =  window.open(encodeURI(link), '_blank', 'location=yes'); 
       ref.addEventListener('loaderror', function(event) { 


        navigator.notification.alert(
             'error: ' + event.message, // message 
             null,   // callback 
             'Title', // title 
             'Ok'     // buttonName 
            ); 

       }); 

      } 
    } 

IOS

function openInApp(link){ 
      console.log("Open Call"+ link); 
      if(link.length<=1){ 
        navigator.notification.alert(
             'Page not found..!', // message 
             null,   // callback 
             'Title', // title 
             'Ok'     // buttonName 
            ); 
      }else{ 
       var ref = window.open(encodeURI(link), '_blank', 'location=no'); 
       ref.addEventListener('loaderror', function(event) { 


        navigator.notification.alert(
             'error: ' + event.message, // message 
             null,   // callback 
             'Title', // title 
             'Ok'     // buttonName 
            ); 
       }); 
      } 
    } 
+0

但我需要調用_system不_blank,因爲我想在外部瀏覽器不inappbrowser。是可能的android? – HellOfACode

+0

手段你不需要地址欄 –

+1

我不是非常確定我們彼此瞭解。現在發生了什麼:我按了一個打開window.open(網址,「_system」)的網址,然後例如海豚或鉻打開取決於sustems默認瀏覽器,然後我按住主頁按鈕之間切換應用程序,但當我點擊我的phonegap應用程序即時通訊不會返回到最後一個狀態,但應用程序是從開始啓動,但我需要返回到我所處的狀態。這可能w母雞打開系統默認瀏覽器中的網址? – HellOfACode

0

會在評論問這個,但人們需要爲50聲譽... :(

在你​​3210你有exit-on-suspend是否啓用?也就是說,您是否有以下<preference>元素?

<cordova> 
    ... 
    <preference name="exit-on-suspend" value="true" /> 
    ... 
</cordova> 
相關問題