I'm using Android, and I've created a Webview which nicely opens my HTML page (page "A").
Now, I want to follow some links I have on page "A", which go to page "B".
If I click on a linkl defined with
<a href="page_b.html">
everything is fine, and the Webview behaves just like a normal browser, goinmg to the selected page.
But if I click a link defined as <a href="page_b.html?param=x">
all I get is a "Web page not found".
The same if I use an anchor like <a href="page_b.html#2">
.
How can I pass parameters between different HTML pages within the same Webview?
EDIT:
Nevermind, I managed to pass the parameter I needed using localStorage.
Of course, after a gazillion dry runs, I discovered I had to enable it in the WebView with settings.setDomStorageEnabled(tru开发者_运维技巧e) :D
In the end, I discovered I had to set settings.setDomStorageEnabled(true)
in the WebView, and the easiest solution for my problem I found was:
In "Page A.html", I intercept the onClick event of the links, and use localStorage to store the id:
$(".link").each(
function()
{
divId=+$(this).attr('id');
$('#'+divId).click(function(e)
{
localStorage.my_id=divId;
});
});
In "Page B.html", I retrieve the stored id:
$(document).ready(
function()
{
divId=localStorage.my_id;
isReady();
});
I can't reproduce the problem, try this:
this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
...
vw = new MyWebView(this);
vw.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress)
{
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle(title);
}
})
;
精彩评论