0

When I try to handle the link click of the html below, WKWebView only opens a blank page. I don't know how to handle the location.href, which causes no call in the swift code. Delegates are set:

    <div><a href="javascript:wopen();">OPEN</a></div>
    <script>
        function wopen() {
            var newWindow = window.open('', '_blank');
            setTimeout(function () {
                newWindow.location.href = 'https://stackoverflow.com';
            }, 2000);
        }
    </script>
SteMa
  • 2,945
  • 2
  • 24
  • 30
  • please check this answer https://stackoverflow.com/questions/20696041/window-openurl-blank-not-working-on-imac-safari – Chandaboy Aug 16 '23 at 10:12
  • thanks for your answer. I have no access to the javascript since it is provided by an external service provider. the problem is the iOS app, where a blank page is opened. When I use Safari, the link is opened normally. – SteMa Aug 16 '23 at 10:38
  • 1
    did you try to use this function userContentController ?? https://stackoverflow.com/questions/24049343/call-javascript-function-from-native-code-in-wkwebview/40730365#40730365 – Chandaboy Aug 16 '23 at 11:05

0 Answers0