0

I have a HTML code with the java Script given below.

<!DOCTYPE html>
<html>
<body style = "text-align:center">
<script>

var out = '';
for (var counter = 1; counter <= 10; counter++) 
    { 
        out += '<img src="http://shiaislamicbooks.com/books_snaps/UR335/'+counter+'.jpg"alt="Page No:'+counter+'" height="100%" width="100%" />';
    } 
document.write(out);
</script>
</body>
</html>

I just want to load this in my android's webview using the loadDataWithBaseURL(null, htmlString ,"text/html", "UTF-8", null); method

  • In short all I need is that how can I convert the above HTML code(Having a java Script Loop) in the htmlString so that I can insert that in loadDataWithBaseURL(null, htmlString ,"text/html", "UTF-8", null); method flexibly

Thanks

1

1 Answer 1

2

The below snippet can help u ...

      webView = (WebView) findViewById(R.id.webView1);
   webView.getSettings().setJavaScriptEnabled(true);
   //webView.loadUrl("http://www.google.com");

   String customHtml = "<html><body><h1>Hello, WebView</h1></body></html>";
   webView.loadData(customHtml, "text/html", "UTF-8");
Sign up to request clarification or add additional context in comments.

1 Comment

please convert my code which i have posted. I m not understanding how and where to place the double quotes ("") in my code please

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.