Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm facing a problem when I create a program by PhoneGap.

in my program, I'm using a local index.html file in my main activity, after the index.html loaded, I'm using window.open to redirect my page to an external page from the other server.

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

now the page redirect to test.html, cordova.js was included in test.html:

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

in test.html, I called the the "exitApp" method of cordora as following:

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

however, I saw the error message as following in ADT logcat: Uncaught TypeError: Cannot call method 'exitApp' of undefined

but this file is working when I call it by local e.g. file:///adnroid_asset/www/test.html

anyone can help me on this? thanks in advance.

share|improve this question
    
This is a bug of cordova 2.7.0, I'm using 2.6.0 and it's working well right now, so I will close this question, thanks. –  user2427792 May 29 '13 at 8:57
add comment

1 Answer

Don't use window.open. Basically it'll try to open it in a new window and you'll lose the reference to Cordova objects. Use:

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

Which will simply load the give url in the same page, keeping the Cordova objects.

More details on the differences here.

share|improve this answer
    
sorry, it doesn't help, the error still there, here is my code: –  user2427792 May 29 '13 at 2:01
    
I found that when I use this file in local, it's working well, but when I call it remotely, I saw there is an error say : Uncaught SyntaxError: Unexpected token <:1 –  user2427792 May 29 '13 at 2:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.