Ok. Not sure if Im doing silly things or not with webview but I sure managed to break a few things along the way here. I finally found a way that works fine (for the time being).
I created a “body” html with all the normal things in it and place it in a custom_resources folder. I also put all the dependcies in there too (css files and js files). Then I load the html body using sys.load_resources which I put into a variable. I also load all the other dependencies and put into a variable.
When I load the dependencies though I made a couple of helper functions (for js and css specifically). They are here:
function loadJSscript( filename )
local text = sys.load_resource(filename)
return "<script>"..text.."</script>"
end
function loadCSSscript( filename )
local text = sys.load_resource(filename)
return "<style>"..text.."</style>"
end
Then I generate my own header like so:
local headerstart = [[
<html class=" js no-touch cssanimations csstransitions" lang="en" style="">
<head>
<meta charset="utf-8">
<title>Project – Scenarist</title>
<meta name="description" content="Describe your website here.">
<meta name="generator" content="GravCMS">
]]
local headerend = "</head>"
Then I add the sections together using string concat in lua like so:
local html = headerstart..cssscript..jsscript..headerend..body
And then load it into webview using open_raw. And it all works. JS works fine, the CSS looks great and I now have a nice html interface that I can interact with the app
Hope this helps others. And if there is a simpler way, Id be happy to hear about it.
Cheers.