iOS 6 multiple UIWebViews: Javascript only runs in one

前端 未结 2 1959
无人及你
无人及你 2021-02-04 17:44

An iOS 6 iPad app shows content in two UIWebViews. If both web views contain a jquery image rotator, only one will work at a time. Running < iOS 6, both work properly.

2条回答
  •  失恋的感觉
    2021-02-04 18:15

    JavaScript works in multiple UIWebViews but it depends on the JavaScript. Using JQuery or other external JavaScript code can be a problem in case you link it with a href. You can solve these issues by copying the code of all external JavaScript libraries into your web page HTML. This is the reason why simple JavaScript works fine. Example:

    Screenshot of JavaScript in multiple web views

    This is a UITableView with a UIWebView in every UITableViewCell. In webViewDidFinishLoad i do [webView stringByEvaluatingJavaScriptFromString:@"document.write('hey hallo'+new Date().getTime())"];

提交回复
热议问题