[Solved]WebBrowserComponent::goToURL() doesn't support anchor link

If a link include ‘#’ (anchor link), goToURL() won’t load, open and position it in WebBrowserComponent.

This issue only appears on macOS, haven’t tested on Linux yet.

Any help? …20 chars.

This might help troubleshoot: http://stackoverflow.com/a/37771617

1 Like

Seems the exactly problem I encountered. That gentleman said he used JavaScript to scroll the web page:

[webView stringByEvaluatingJavaScriptFromString:[NSString swf:@"window.location.hash='%@';",anchorName]];

To my shame, Swift language is so strange to me and I only know a little about JavaScript. So, anyone could kindly translate the sentence above to JUCE C++?


Wait a minute… perhaps I could solve this problem myself…

Here is the code, hope this’ll help someone.

    webBrowserComponent->goToURL ("javascript:location.hash=\"" + anchorStr + "\";");
    webBrowserComponent->goToURL (currentUrl + "#" + anchorStr);

Thank you, @jrlanglois !