我必须使用javascript stringbyevaluatingstring
显示UIWebView内容。iphone uiwebview超链接
在我的项目中,超链接不起作用。如何启用UIWebView中的所有链接?
有人知道的话请给出一段样片代码或想法。
我必须使用javascript stringbyevaluatingstring
显示UIWebView内容。iphone uiwebview超链接
在我的项目中,超链接不起作用。如何启用UIWebView中的所有链接?
有人知道的话请给出一段样片代码或想法。
只是一个样本尝试:在UIViewController中
谁“拥有”你的UIWebView命名为:“yourWebView”
// navigate to a new html file:
[yourWebView stringByEvaluatingJavaScriptFromString:@"document.location='aNewHtmlFile.html'"];
// show a normal javascript alert window with a message:
[yourWebView stringByEvaluatingJavaScriptFromString:@"alert('This is what an alert message looks like.');"];
// ask to the html file its own title:
NSString *appS = [yourWebView stringByEvaluatingJavaScriptFromString:@"document.title"];
NSLogg(@"the title is: %@", appS);
// call a personal JS in your html document:
[yourWebView stringByEvaluatingJavaScriptFromString:@"callMyJSFunctionToshowMyAlert('Hallo!');"];
// whit this in your html file:
<head>
...
<script>
function callMyJSFunctionToshowMyAlert(aMsg) {
alert(aMsg);
}
</script>
...
</head>
如果一些funcs中的不那么工程可能存在一定的误差当你实例化你的UIWebView加载html文件的地方。 但是你在找什么?
谢谢,这对我非常有用。抱歉迟来的谢谢。 。 – suresh 2011-08-19 10:05:16
你可以发布你正在使用的代码吗?你的问题非常模糊。 – TNC 2011-02-24 06:35:28