I'm currently trying to render sheet music HTML (which I generate with a javascript library) in a webview. Here is my code:
ViewController.swift (partial):
let web = WKWebView()
let localfilePath = NSBundle.mainBundle().URLForResource("index", withExtension: "html")
let myRequest = NSURLRequest(URL: localfilePath!)
web.loadRequest(myRequest)
index.html:
<html>
<script src="http://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
<script src="http://www.vexflow.com/support/vexflow-min.js"></script>
<script src="http://www.vexflow.com/support/tabdiv-debug.js"></script>
<body>
<h1 id="someElement"> Test </h1>
<div style="width:680; margin-left: auto; margin-right: auto;">
<div class="vex-tabdiv">
options width= 700 space=20
tabstave notation=true key=A time=4/4
notes :q =|: (5/2.5/3.7/4) :8 7-5h6/3 ^3^ 5h6-7/5 ^3^ :q 7V/4 |
notes :8 t12p7/4 s5s3/4 :8 3s:16:5-7/5 :h p5/4
text :w, |#segno, ,|, :hd, , #tr
</div>
</div>
</body>
</html>
While the HTML does load, it is not correctly rendered. If I render this HTML in Chrome, it will look like this:
Yet, when I try running it within my webview, I get:
As you can see, the HTML is rendered without the JS. I've dug through Google/SO and have tried various things like making the JS files local and importing them as
<script src="lodash.js"></script>
as well as using WKWebView's executeJavascript function to no avail, but I must be missing something.. many thanks in advance!

