Search code examples
iphoneobjective-cios4

Using anchor tag with UIwebview?


I am using xml content to display in a webview.I am storing a xml content in string and giving it to html content like this.

NSString* string = [NSString stringWithFormat:@"<a id=\"2001\"><p>how to load the webview</p></a>",];
 NSString* string1 = [NSString stringWithFormat:@"<a id=\"2002\"><p>load the webview</p></a>",];
static NSString *htmlTemplate = @"<!DOCTYPE html><html>"
"<head><title>nothing</title></head>"
"<body>"
"<p> %@ </p>"
"<p> %@ </p>"
"</body>"
"</html>";

 NSString* r = [NSString stringWithFormat:htmlTemplate,string,string1];

and i am using a button if i click the button it needs to go 2002 tag how to do that .


Solution

  • [webview stringByEvaluatingJavaScriptFromString:@"window.location.hash = '2002'"];