iOS loadHtmlString in UIWebView doesn't work with Javascript

后端 未结 3 567
深忆病人
深忆病人 2021-02-15 01:36

I have a iOS app to load a html string which refer to external css file and javascript file in the same directory.

Here is my html file:


&l         


        
3条回答
  •  梦如初夏
    2021-02-15 02:19

    This question is a bit old, but since it has not been answered, I would like to point out that if you would like your web view to load a javascript file residing in your bundle, the way to do it is:

    [webView loadHTMLString:html
                   baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
    

    If you don't specify the baseURL there is no chance that the javascript file is loaded.

提交回复
热议问题