How to reference HTML anchor?

后端 未结 2 2050
眼角桃花
眼角桃花 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.

    0 讨论(0)
  • 2021-01-20 00:21

    If I'm not mistaken, just add #go%20here to the end of the URL

    EDIT: ahh you mean already loaded. Is it really out of the question to just do reload the page? The browser should have cached most of it anyways...

    0 讨论(0)
提交回复
热议问题