2013-05-28 39 views
0

我在通過PhoneGap創建程序時遇到問題。我在我的主要活動中使用本地index.html文件,在index.html加載後,我使用window.open將我的頁面從另一個服務器重定向到外部頁面。使用PhoneGap外部URL但Cordora js不能在Android中工作

window.open("http://192.168.0.11/test.html", '_self'); 

現在的頁面重定向到的test.html,cordova.js被列入的test.html:

//included the cordova js file in test.html file 
<script src="js/cordova.js"></script> 

中的test.html,我叫cordora的 「ExitApp命令」 方法如下:

function onExit() 
{ 
    navigator.app.exitApp(); 
} 

但是,我看到了錯誤信息如下在ADT的logcat: 遺漏的類型錯誤:無法調用未定義

法「ExitApp命令」

但這個文件正在工作,當我打電話給本地例如file:///adnroid_asset/www/test.html

任何人都可以幫助我呢?提前致謝。

+0

這是cordova 2.7.0的一個bug,我使用的是2.6.0,現在運行良好,所以我會關閉這個問題,謝謝。 –

回答

-1

請勿使用window.open。基本上它會嘗試在新窗口中打開它,並且會失去對Cordova對象的引用。使用:

window.location.href = "http://192.168.0.11/test.html" 

這將簡單地加載到相同的頁面,保持科爾多瓦對象的URL。

更多細節差異here

+0

對不起,它沒有幫助,錯誤仍然存​​在,這裏是我的代碼: –

+0

我發現當我在本地使用這個文件時,它運行良好,但是當我遠程調用它時,我看到有一個錯誤說:未捕獲的SyntaxError:意外的標記<:1 –

相關問題