Gaurav Arora
Gaurav Arora

Reputation: 17264

Error changing element height in webview using javascript

I want to change height of a field in webView(Android). I tried doing it using a javascript but it doesn't work.

webView.loadUrl("javascript:(var field = document.getElementById("targetdiv");field.style.height='50px;);");

I've also enabled javascript:

WebSettings ws = webView.getSettings();
ws.setJavaScriptEnabled(true);

Still it doesn't work. Please help me out !

Upvotes: 0

Views: 212

Answers (1)

Thariama
Thariama

Reputation: 50832

This works along like this

myWebView.loadUrl("javascript:showString('Hello World!')");

where showStringis a function that outputs the given string (not shwon here).

Upvotes: 1

Related Questions