我正在尝试在视图寻呼机中加载 webviews。
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = null;
v = inflater.inflate(R.layout.webview_layout, container, false);
myWebView = (WebView)v.findViewById(R.id.webview1);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setAppCacheEnabled(true);
webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
myWebView.loadUrl("file:///android_asset/web/index.html");
myWebView.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
myWebView.loadUrl("javascript:testFunction()");
}
}
}
加载页面后,在以正常速度滚动网页时调用 javascript 函数onPageFinished()
并执行 javascript。
但是在高速滚动时会发生以下异常。
> 09-06 14:29:06.750: E/Web Console(8272): Uncaught ReferenceError:
> testFunction is not defined:1
testFunction() 是
function testFunction(){
console.log("TestFuntion");
}
请帮忙...