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

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -