Univer
Univer

Reputation: 325

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 .

Upvotes: 0

Views: 1596

Answers (2)

Luke James Stephens
Luke James Stephens

Reputation: 412

Swift 3.0

aWebView.stringByEvaluatingJavaScript(from: "window.location.hash = 'Infrastructure'")

Upvotes: 0

rob mayoff
rob mayoff

Reputation: 385890

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

Upvotes: 1

Related Questions