1

I'm trying to access a site using embedded browser within my app, and I noticed that one major link is not responding at all when I try clicking it.

After inspecting the page html, I found the link:

<a href="javascript:doSomething()" ...></a> 

How can I make WKWebview execute the javascript inside the link? I tried extending the delegate and implementing didChangeURL, but I couldn't catch it there (other url did went through the function).

I'm really out of options, is there a way to fixing this issue? native browser handle it as expected...

Thanks.

Nadav96
  • 1,274
  • 1
  • 17
  • 30
  • this is late, but did you try extracting the value for the href attribute and then inject the source using an eventListener? – ɯɐɹʞ Jul 18 '17 at 17:32

1 Answers1

0

Unless there's a reason you're using link javascript, I expect you'll get more consistent performance across the board if you just used onclick on a regular div, and then styled it to look like a link.

Or, even better, avoid handlers in the markup in general: Better way to call javascript function in a tag

Community
  • 1
  • 1
Aaron Pool
  • 479
  • 2
  • 6
  • The issue is I have no control over the site, so I need to fit the app to it. – Nadav96 Dec 14 '16 at 18:51
  • There are a lot of bugs/inconsistencies with WKWebview behavior vs a regular browser. If you have no control over the site, you may be out of luck. Although, I admit, I've only been on the other side of this coin. The person debugging as the developer, so I'm in no way a WKWebview expert. – Aaron Pool Dec 14 '16 at 18:54