• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps facing problem with webview. can any body help?

rafiqsab

Lurker
hi,
Developing a application on webview.

have an fronthtml file which is emty and and have place holders for the contents. and have javascript function like bellow.

// this is function from fronthtml page
function adddata(dataHTML) {
var newdataDiv = document.createElement("div");
newdataDiv.innerHTML = dataHTML;

var element = document.getElementById('outer');
element.appendChild(newdataDiv);

}
//------------------------------------------------------------------------------
6.html has bellow div

<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"></head><body><div class="tile-group">
<div style="width: 324px; background-color:LightGrey; height:186px; margin-left:0px; margin-right: 0px; float: left; margin-bottom: 0px; margin-top: 0px" class="tile" id="389">
<a href="somelink" class="showlink">
<div class="title">Digital Britain: Creative and Tech Talent Landscape</div>
<div style="float: left; width: 315px; margin-left: 3px">
<div style="float: left; width: 110px">
<img src="6_files/5.png" alt="Digital india: " height="100" width="100">
</div>
<div style="float: left; width: 200px;" class="type">
<div style="float: left; height: 30px">
<p>Blogs 7/12/2011</p></div>
<div style="clear: both; float: left; height: 35px">
<p>Blog</p>
</div>
<div style="clear: both; float: left; height: 40px">
<div class="rating">
* * * * * <span>(12 ratings)</span></div>
</div>
</div>
</div>
<div class="description">
<p>some text</p>
</div>
</a>
</div>

</div></body></html>
//------------------------------------------------------------------------------
i am using the bellow code to call the javascript function. passing 6.html link as input

public class TestwebdemoActivity extends Activity {
WebView mWebView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);



mWebView = (WebView) findViewById(R.id.webView1);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebViewClient(new MyWebChromeClient());

mWebView.loadUrl("file:///android_asset/fronthtml.html");
}

final class MyWebChromeClient extends WebViewClient {

@Override
public void onPageFinished(WebView view, String url)
{

mWebView.loadUrl("javascript:adddata("+"file:///android_asset/6.html"+")");

}
}
}

//--------------
above code is not working... is there any problem with passing parameters or javascript function?

or can we pass link as input to the adddata javascript function?

its very urgent for me please help me in this regards.

thanks and regards
rafiq
 
Back
Top Bottom