Forum Xamarin.iOS

How can I load local javascript using wkwebview?

RichardBlotevogelRichardBlotevogel USMember
edited July 2017 in Xamarin.iOS


I am currently trying to load a local html file using wkwebview. The issue I am having is that when I use the LoadFileUrl() it is showing a blank screen. The didfinishnavigation() is called and it looks as though it is trying to load the correct file, but nothing is showing on the screen. I was able to, successfully, get the local html file to show and work properly using uiwebview. Below is the code that I am using to load the url. The filename contains the path along with the html file appended at the end. Path is the path with the directory that contains all of my local files. The local files consist of some png images, some js files and some other html files.

        var path = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        var nsurl = NSUrl.CreateFileUrl(new[] { filename });
        var refurl = NSUrl.CreateFileUrl(new[] { path });

        wkView.LoadFileUrl(nsurl, refurl);

I am unsure as to why it is not loading the html correctly. Any help would be greatly appreciated.


Sign In or Register to comment.