seems the page was reloaded after call goBack(), is there any way to
prevent reload page after call goBack() ???

On 11月18日, 下午6时23分, alex <[email protected]> wrote:
> I have a problem that when I click back button on a WebView, my
> previous page losts all contents updated by JavaScript.
>
> My steps in WebView was below:
> - after Main page loaded, JavaScript starts update contents, like
> refresh shoppings with links;
> - user will see some shopping lists after updated;
> - then user click each link will load new url in same WebView;
> - user click back to Main page;
>
> the problem is when user back to Main page, user cannot see any
> shopping updated by JavaScript, they were gone!
> I tried my page on IE and FF, both works fine, but had problem on
> Android WebView. I'm not sure this issue caused by I'm not set some
> settings correctly or other issues.
>
> My sample code as below:
>
> // set settings for webview
>         WebSettings webSettings = web.getSettings();
>         webSettings.setBuiltInZoomControls(true);
>         webSettings.setJavaScriptEnabled(true);
>         webSettings.setUseWideViewPort(true);
>         webSettings.setDomStorageEnabled(true);
>         webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
>
> // call JavaScript to update shoppings
>         webView.loadUrl("javascript:addShoppings(" + str + ");");
>
> // add interface for callback
>         webView.addJavascriptInterface(new
> BusinessJavaScriptInterface(), "business");
>
> final class BusinessJavaScriptInterface
> {
>     public void businessListReceived()
>     {
>         ... ...
>     }
>
> }
>
> // handle back key event
>     public boolean onKeyDown(int keyCode, KeyEvent event)
>     {
>         WebView web = (WebView) this.findViewById(R.id.browser);
>         if (web != null)
>         {
>             if ((keyCode == KeyEvent.KEYCODE_BACK) && web.canGoBack())
>             {
>                 web.goBack();
>                 return true;
>             }
>             return super.onKeyDown(keyCode, event);
>         }
>         return false;
>     }

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to