Javascript iphone uiwebview超链接
我必须使用javascriptJavascript iphone uiwebview超链接,javascript,iphone,ipad,uiwebview,Javascript,Iphone,Ipad,Uiwebview,我必须使用javascriptstringbyevaluatingstring显示UIWebView内容 在我的项目中,超链接不起作用。如何启用UIWebView中的所有链接 如果有人知道,请给出一段示例代码或想法。只需一个示例即可: 在“拥有”名为“yourWebView”的UIViewController中 //导航到新的html文件: [yourWebView stringByEvaluatingJavaScriptFromString:@“document.location='aNewH
stringbyevaluatingstring
显示UIWebView内容
在我的项目中,超链接不起作用。如何启用UIWebView中的所有链接
如果有人知道,请给出一段示例代码或想法。只需一个示例即可:
在“拥有”名为“yourWebView”的UIViewController中
//导航到新的html文件:
[yourWebView stringByEvaluatingJavaScriptFromString:@“document.location='aNewHtmlFile.html'”;
//显示带有消息的普通javascript警报窗口:
[yourWebView stringByEvaluatingJavaScriptFromString:@“警报('这是警报消息的样子');”;
//要求html文件有自己的标题:
NSString*appS=[yourWebView stringByEvaluatingJavaScriptFromString:@“document.title”];
NSLogg(@“标题为:%@”,应用程序);
//在html文档中调用个人JS:
[yourWebView stringByEvaluatingJavaScriptFromString:@“callMyJSFunctionToshowMyAlert('Hallo!');”;
//在html文件中添加以下内容:
...
函数调用MyJSFunctionToShowMyAlert(aMsg){
警报(aMsg);
}
...
如果其中一些函数不起作用,那么在实例化UIWebView加载html文件时,可能会出现一些错误。
但是您在寻找什么呢?是否设置了UIWebView-检测链接的属性?是否可以发布您正在使用的代码?你的问题很模糊。在IB的网页视图属性中,你可以设置网页链接的检测。谢谢这对我很有用。对不起,迟到了,谢谢。
// 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>