5 Replies
      Latest reply: Feb 27, 2017 1:11 AM by eskimo RSS
      M7. Level 1 Level 1 (0 points)
        <html>
            <head>
                <script type='text/javascript'>
                function skipButtonTapped()
                {
        
        
             }
                 
                  var pinID = 0;
                  function ping() {
                    var message = 'hello ' + Date.now();
                    document.title = message;
                    window.location.hash = pinID++;
                    return false;
                  }
                </script>
           
            </head>
            <body style='overflow-x:hidden;overflow-y:hidden;'>
                <h2 style = "font-size:16px;" align='center'>Hi Welcome to Webpage</h2>
                <br/>
        
        
                    <input type='button' style='width:90px;height:30px;' onClick="window.location.hash = ping()" value='click me'>
                </center>
               
                 
            </body>
        </html>
        

        i have this page iam already show it in uiwebview ios app and i want user onclick or javascript function to go into another view controller for native code ...

        • Re: button in uiwebview call second view native code
          eskimo Apple Staff Apple Staff (6,660 points)

          This is much easier if you use WKWebView rather than UIWebView because WKWebView has much better support for web/native integration.  Specifically, in WKWebView you can add a script message handler (WKScriptMessageHandler) that you can invoke directly from JavaScript.  A good place to start here is this doc.

          Unless you have a hard requirement to stick with the older UIWebView, I recommend you make the jump to WKWebView, which will help with this and many other issues.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"