android - Inject <link> and <script> in webview -
@override public void onpagefinished(webview view, string url) { super.onpagefinished(view, url); view.loadurl("javascript: function(){" + "var newlink = document.createelement('link');" + "newlink.setattribute('rel', 'stylesheet');" + "newlink.setattribute('href', 'http://maven.com/slide/caca.css');" + "document.getelementsbytagname('head').item(0).appendchild(newlink);" + "}"); }
but thing won't run ok. expecting webview download css , set in page.
basically want add remote css , js files webview.
any ideas on how accomplish this? don't want manually download content of files, cache them or whatnot, , set them in webview.
apparently works. not entirely sure why though ...
view.loadurl("javascript:(function() { " + "var script=document.createelement('link'); " + " script.setattribute('type','text/css'); " + " script.setattribute('rel','stylesheet'); " + " script.setattribute('href', 'http://maven.com/slide/caca.css'); " + "document.head.appendchild(script); " + "})();");
anyway ... 7 hours right down drain ...
Comments
Post a Comment