1

I added html page on webview. I want to capture button action when I click the button. These are my javascript codes;

<div>
    <input type="button" value="Hide Bottom Menu" onClick="hideBottomMenu(true)" />
</div>
<script language="javascript">
        function hideBottomMenu(isHide){
            Bridge.hideBottomMenu(isHide);
        }
</script>

These are my objective-c codes;

I called html page on viewdidload, there is no problem to see html page.

NSString *htmlFile = [[NSBundle mainBundle] pathForResource:@"bridge" ofType:@"html"];
NSString* htmlString = [NSString stringWithContentsOfFile:htmlFile encoding:NSUTF8StringEncoding error:nil];
[_webView loadHTMLString:htmlString baseURL:nil];

UIWebView delegate methods;

-(void)webViewDidFinishLoad:(UIWebView *)webView{
    [_webView stringByEvaluatingJavaScriptFromString:@"hideBottomMenu()"];
}

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

    return YES;
}

When I click the button on webview, UIWebview delegate method (shouldStartLoadWithRequest) not calling.I want to capture button action from there.

Can anybody help me? Thank you, Halil.

1 Answer 1

2

you can find something useful helpful here http://www.joshuakehn.com/2014/10/29/using-javascript-with-wkwebview-in-ios-8.html

but for this you would need to use wkwebview

Sign up to request clarification or add additional context in comments.

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.