I am writing some code in IBM's Worklight which uses Apache Cordova.
I am trying to open the InAppBrowser, and instead of having the user click "done" when finished, I want it to automatically close itself when a specific URL is loaded. Is this possible?
The scenario:
I basically direct the user to twitter.com (easier than using oauth process) and just have the user use twitter within the InAppBrowser browser, but once the user has logged in (the url becomes the news feed url) I want to redirect the user directly to the post URL, and once posted, back to the app, if possible.
Edit (May 1st, 2014)
Following the suggestion in the answer below, I am able to direct the user to the post page, however as soon as it finishes loading it redirects to the home page, without actually being able to send a tweet. Is there a way to fix this? Also, the InAppBrowser never exits.
Also, the below code only works if the user is already logged in. Is there a way to say like, if the user is not logged in go to the main page, if they are go to the post page?
// open InAppBrowser w/out the location bar
var ref = window.open('http://mobile.twitter.com/compose/tweet', '_blank', 'location=no');
// attach listener to loadstart
ref.addEventListener('loadstart', function(event) {
var urlSuccessPage = "http://mobile.twitter.com";
if (event.url == urlSuccessPage) {
ref.close();
}
});