I am building an application using PhoneGap for Android that can also be uploaded to a server and used as a website.
The problem I'm having is that on the login page I have a JSON call to a php page to check the login credentials and this only works if the user has typed in the full url Including the www., otherwise it returns a json cross-domain error.
I solved this problem using the code below which adds the 'www.' if its not found.
if (document.URL.toLowerCase().indexOf("www.") == -1) {
var new_url = document.URL.slice(0, 7) + "www." + document.URL.slice(7);
window.location = new_url;
}
I need to check to see if the user is using the application as a website and call the code above, or if they are using it as an Android app, skip the code above. At the moment the Android app tries to redirect when it hits this code, giving a network error.
Any help is appreciated, Thanks.