开发者

Manipulate the HTMLloaded in a webview control

I have a webview control to wh开发者_如何学运维ich i am loading a page form a website. I want to include a CSS file to the webpage once it is loaded. Is there any way i can get accesses to the content that is loaded in the webview?

I have no control over the website, so changeing the code there is not an option.


You can execute javascript from java by using loadUrl method.

mWebView.loadUrl("javascript:alert('hello world')");

Afterwards you can set css by using javascript method

var obj= document.getElementById(obj);
obj.style.visibility = "visible";

You can find a code sample to execute javascript from java code at WebViewDemo application here

http://code.google.com/p/apps-for-android/source/browse/#svn/trunk/Samples/WebViewDemo

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜