diegoveloper
diegoveloper

Reputation: 103541

Android - JQUERY problem on Webview using loadDataWithBaseURL

I'm trying to show a jquery mobile webpage on my webview, but I'm having problems with some events, for example: This is the test webpage that I'm trying to show :

http://jquerymobile.com/demos/1.0b2/docs/pages/multipage-template.html#one

When I use this :

webView.loadUrl("http://jquerymobile.com/demos/1.0b2/docs/pages/multipage-template.html#one");

I don't have any problem rendering the page also the events works fine, but I need to use loadDataWithBaseURL instead loadUrl on my application.

When I use this :

String htmlData = convertStreamToString(getAssets().open("page.txt"));
webView.loadDataWithBaseURL("http://jquerymobile.com/demos/1.0b2/docs/pages/multipage-template.html#one", htmlData, "text/html", "UTF-8", null);

Where page.txt is the source code of the page and htmlData the html code in String. It renders the page, click on Show page "two" works well also back to page one, but I have problem when I enter to Show page "popup" , the close button for the popup doesn't work neither Back to page "one" button in the dialog.

Anybody know what could be happen? Thanks!

Upvotes: 2

Views: 1730

Answers (1)

diegoveloper
diegoveloper

Reputation: 103541

Solved!, I added the historyUrl the same as the baseUrl and works!

final String baseURL = 
"http://jquerymobile.com/demos/1.0b2/docs/pages/multipage-template.html#one";

webView.loadDataWithBaseURL(baseURL, htmlData, "text/html", "UTF-8", baseURL);

Upvotes: 1

Related Questions