开发者

How to hyperlink android html assets when using chrome client?

I have a main page (main.html) in the assets folder that I am displaying with:

webview.setWebChromeClient(new MyWebChromeClient());
webview.getSettings().setJavaScriptEnabled(true);
webview.addJavascriptInterface(new VersionCallbackScript(), "demo");
webview.loadUrl("file:///android_asset/main.html");

and I want to put a link in the document to another html file in assets folder. When I similiarly put in the tag:

<a href="file:///android_asset/secondpage.html">Touch here for page 2</a></font></h4>

and touch it in the client, the screen loads a blank page.

likewise, I want to have a table of contents that isA ListView and uses loadUrl with an html page suffixed with an anchor. I tried and it is not working

String ancho开发者_JAVA百科r = "subsection1";
webview.loadUrl("file:///android_asset/main.html" + "#" + anchor);

this construct is not working either.


Give a try to the following piece of code

<a href="secondpage.html">Touch here for page 2</a>

For me it does the job.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜