title: WKWebView not able to recognize the text returned by JavaScript
body: <p>I am using a WKWebView in my iOS app to display an HTML string. Now I need to let my app capture the word being tapped in the HTML page. I have a piece of jQuery code embedded in the HTML to capture the word and then redirect the page to a fake URL including this word. And in the WKWebView's WKNavigationDelegate method "decidePolicyFor", I parse the requested URL to retrieve the word. Everything works well except that the word itself is gone. I tried the same HTML page on Safari and the redirecting URL is totally correct which I can confirm in the URL address. I don't know what's wrong between the jQuery code and WKWebView. Any advice would be most appreciated.</p>
  
  <p>My HTML string:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;header&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt;
          &lt;script&gt;
              $(document).ready(function() {
  
                                var p = $('p');
  
                                p.click(function(e) {
                                        var sel_obj = window.getSelection(); //it will return an object
                                        sel_obj.modify("move","forward","character");
                                        sel_obj.modify("extend","backward","word");
  
                                        sel_obj.modify("move","backward","character");
                                        sel_obj.modify("extend","forward","word");
  
                                        var text = sel_obj.toString().trim();
                                        text = text.toLowerCase();
                                        window.location = "https://www.anonexistent.com/wordclicked/" + text;
                                        });
  
                                });
              &lt;/script&gt;
      &lt;/header&gt;
  
      &lt;body&gt;
          &lt;h1&gt;CLICK-TO-PICK-THE-WORD&lt;/h1&gt;
          &lt;br/&gt;
          &lt;br/&gt;
          &lt;p&gt;&lt;font size=20&gt;Baa Baa Black Sheep&lt;font&gt;&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My iOS code (in Swift):</p>
  
  <pre><code>func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -&gt; Void) {
  
      let redirectURLString = navigationAction.request.url?.absoluteString ?? ""
      print("redirectURLString: \(redirectURLString)")
  
      if redirectURLString == "about:blank" {
          decisionHandler(WKNavigationActionPolicy.allow)
      }
      else {
          decisionHandler(WKNavigationActionPolicy.cancel)
      }
  }
  </code></pre>
  
  <p>Now the page is showing correctly. And when I tap the word "Sheep" in the paragraph, jQuery can recognize the word and construct the redirecting URL as</p>
  
  <pre><code>https://www.anonexistent.com/wordclicked/sheep
  </code></pre>
  
  <p>which I have verified on Safari. The problem is that in Xcode, navigationAction.request.url?.absoluteString is only</p>
  
  <pre><code>https://www.anonexistent.com/wordclicked/
  </code></pre>
  
  <p>and the word "sheep" is missing.</p>