How to reference HTML anchor?

后端 未结 2 2078
眼角桃花
眼角桃花 2021-01-20 00:00

I\'m loading a string of HTML into a UIWebView through loadHTMLString. It produces a very long webpage. Once that string is loaded, I need to navigate to an HTML anchor ta

2条回答
  •  青春惊慌失措
    2021-01-20 00:20

    you can jump to an anchor in an already loaded HTML file by doing:

    [webView stringByEvaluatingJavaScriptFromString:@"window.location.hash='#foo'"];
    

    this will do the jump, sans animation.

提交回复
热议问题