简体   繁体   中英

iOS WKWebview not responding to clicks events on <a href=“javascript:doSomething()” …></a>

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM