2012-05-03 100 views
2

我正在将jqueryMobile html文件加载到webview中,并正确触发了webViewDidFinishLoad事件。但是,当您选择载入另一个HTML文件内容的已加载jqMb文件的导航按钮时,事件不会被触发!如何捕捉它?谢谢iOS + jqueryMobile加载html文件时无法捕获webview事件

+0

您可以使用jQuery Mobile的暴露JavaScript事件:http://jquerymobile.com/demos/1.1.0/docs/api/events.html。请参阅'pageinit',它是jQuery Mobile的'document.ready'。 – Jasper

+0

当按钮被按下时,我可以在jqueryMobile上正确捕获事件!但如何触发本地webview事件? shouldStartLoadWithRequest – Jaume

+0

使用假javascript调用解决,widow.location =“localFuction”。然后 - (BOOL)webView:(UIWebView *)如果if([[[request URL] absoluteString] hasPrefix:@“localFunction”]){{return NO;}}将触发webView shouldStartLoadWithRequest。希望这会有所帮助 – Jaume

回答

1

使用假javascript调用,widow.location = "localFuction"解决。

然后,- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest被触发,如果([[[request URL] absoluteString] hasPrefix:@"localFunction"]) { Return NO;

希望这有助于

+0

我知道这是一个旧的帖子,但你在哪里/如何调用'window.location =“localFunction”'? – adamdehaven