Inject inline script in cordova wkwebview IOS -
alright, i've seen threads can't seem work.
<meta http-equiv="content-security-policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src *; img-src *">
if directly add:
<script type="text/javascript"> alert('hello world'); </script>
this works.
..but.. if inject localstorage crashes app. can inject html , css fine though.
i have these npms installed:
<plugin name="cordova-plugin-wkwebview-engine" spec="git+https://github.com/apache/cordova-plugin-wkwebview-engine.git#1.0.0" /> <plugin name="cordova-plugin-wkwebview-file-xhr" spec="^1.0.0" />
i use small function load it. works uiwebview
nate.createscript = function(input){ var head = document.getelementsbytagname('head')[0] var el = document.createelement('script') el.setattribute('type', 'text/javascript') el.innertext = input head.appendchild(el) }
and localstorage looks like:
localstorage.js = "alert('hello world')"; nate.createscript(localstorage.js)
Comments
Post a Comment