1

it's a little bit confusing I know but let's try. i have uiwebview in my iphone app and it's loaded with html local file from the bundel .. I want to put html button in this file that can load another local file using javascript ... is that possible?? is there any other approach but that ..

any help will be appreciated

0

2 Answers 2

3

You can do a custom protocol bridge between the web page and your app as the following :

In you HTML page , you may add the following a tag for example :

<a href='ToThePage2'>Click Here</a>

And in your app you'll handle this event by the following code :

webView.delegate = self;

- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
NSURL *url = request.URL;
NSString *urlString = url.absoluteString;
if([urlString isEqualToString:@"ToThePage2"])
{
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"theNextHTMLPage" ofType:@"html"]isDirectory:NO]]];
return NO;
}
return YES;
}
Sign up to request clarification or add additional context in comments.

Comments

0

Loading javascript into a UIWebView from resources

In this link they have loaded local html file using javascript.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.