问题描述
正如你可能知道,Android的的WebView有一个名为方法 addJavascriptInterface()
进口一个Android Java对象的Javascript环境。
As you may know, Android's WebView has a method named addJavascriptInterface()
which imports an Android JAVA object to Javascript context.
问题是,是否有它的iOS任何等价?
the question is, Is there any equivalent of it on iOS?
推荐答案
UIWebView的iOS上没有方法接口添加到DOM。
但你还是可以跟你的code从JavaScript分配的东西 window.location的
和处理该请求web视图:shouldStartLoadWithRequest:navigationType:
委托方法。
UIWebView on iOS doesn't have methods to add interface to DOM.
But you still can talk to your code from javascript assigning something to window.location
and handling that request in webView:shouldStartLoadWithRequest:navigationType:
delegate method.
这篇关于Android的addJavascriptInterface相当于iOS中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!