Reputation: 830
Using Childbrowser. My case:
I want to redirect/forward Childbrowser to my index.html of phone gap? How can I do it?
js-file:
// Callback when the user chooses the 'Done' button // called from native
ChildBrowser._onClose = function()
{
window.plugins.childBrowser.onClose();
};
Code Snippet from .m file:
- (void)closeBrowser
{
if (self.delegate != nil) {
[self.delegate onClose];
}
if ([self respondsToSelector:@selector(presentingViewController)]) {
// Reference UIViewController.h Line:179 for update to iOS 5 difference - @RandyMcMillan
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
}
- (IBAction)onDoneButtonPress:(id)sender
{
[self closeBrowser];
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[self.webView loadRequest:request];
}
And the other .m file:
- (void)close:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url
{
[self.childBrowser closeBrowser];
}
- (void)onClose
{
[self.webView stringByEvaluatingJavaScriptFromString:@"window.plugins.childBrowser.onClose();"];
}
Upvotes: 0
Views: 172
Reputation: 23273
In your onClose handler set document.location to index.html. Should be as simple as that.
Upvotes: 1