title: Use WKWebView to inject javascript in second web page
body: <p>In an iOS app, I need to navigate a complicated web site using WKWebView.  I am able to bring up the first web page; let's call it <em>A.html</em>.</p>
  
  <pre><code>NSURL *url = [NSURL URLWithString:@"http://foo.com/A.html"];
  NSURLRequest *request = [NSURLRequest requestWithURL:url];
  [_webView loadRequest:request];
  </code></pre>
  
  <p>This works fine.  In my didFinishNavigation event, I can inject a function call that is internal to <em>A.html</em>, e.g.:</p>
  
  <pre><code>NSString* js = [NSString stringWithFormat:@"someJavascriptFunc();"];
  [self.webView evaluateJavaScript:js completionHandler:^(id response, NSError * error) {
      NSLog(@"Error: %@",error);
  }];
  </code></pre>
  
  <p>Now I have executed some javascript in <em>A.html</em>, and it has caused another page to load, <em>B.html</em>.</p>
  
  <p>Now I want to inject a javascript command in <em>B.html</em>. I think I need to set up another WKWebView object but it's not clear how I chain it to the first one, or what event handler I would use.</p>
  
  <p>What I'm trying to do is simulate NFC taps in iOS; tap a tag and it takes you to B.html, which then prompts you for another tag.  Tap the second tag and it takes you to the web page you need.  This is where I'm stuck. Is this even possible?  I can't modify the javascript in <em>A.html</em> and <em>B.html</em>, so I am hoping to simulate these tap events in WKWebview.</p>