當前位置: 首頁>>代碼示例>>Java>>正文


Java WebView.evaluateJavascript方法代碼示例

本文整理匯總了Java中android.webkit.WebView.evaluateJavascript方法的典型用法代碼示例。如果您正苦於以下問題:Java WebView.evaluateJavascript方法的具體用法?Java WebView.evaluateJavascript怎麽用?Java WebView.evaluateJavascript使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.webkit.WebView的用法示例。


在下文中一共展示了WebView.evaluateJavascript方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
public void onPageFinished(WebView view, String url) {
	if (view.isShown()) {
		mBrowserController.updateUrl(url, true);
		view.postInvalidate();
	}
	if (view.getTitle() == null || view.getTitle().isEmpty()) {
		mTitle.setTitle(mActivity.getString(R.string.untitled));
	} else {
		mTitle.setTitle(view.getTitle());
	}
	if (API >= android.os.Build.VERSION_CODES.KITKAT && mInvertPage) {
		view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
	}
	mBrowserController.update();
}
 
開發者ID:NewCasino,項目名稱:browser,代碼行數:17,代碼來源:LightningView.java

示例2: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    final String password = profile.getString("password", null);
    final String username = profile.getString("username", null);
    if(profile.getString("username",null).equals("default") || profile.getString("password",null).equals("default"))
    {
        Toast.makeText(getApplicationContext(),"Enter your login details properly !",Toast.LENGTH_LONG).show();
        Intent log = new Intent(Moodle.this,LoginActivity.class);
        startActivity(log);
        return;
    }
    final String js = "javascript:" +
            "document.getElementById('password').value = '" + password + "';" +
            "document.getElementById('username').value = '" + username + "';" +
            "document.getElementById('loginbtn').click()";
    if (Build.VERSION.SDK_INT >= 19) {
        view.evaluateJavascript(js, new ValueCallback<String>() {
            @Override
            public void onReceiveValue(String s) {

            }
        });
    } else {
        view.loadUrl(js);
    }

}
 
開發者ID:ashutoshbsathe,項目名稱:COEP-Moodle-via-Webview,代碼行數:30,代碼來源:Moodle.java

示例3: myEvaluateJavaScript

import android.webkit.WebView; //導入方法依賴的package包/類
private void myEvaluateJavaScript(WebView webView, String script) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(script, null);
    } else {
        webView.loadUrl("javascript:" + script);
    }
}
 
開發者ID:akhilkedia,項目名稱:AllTrans,代碼行數:8,代碼來源:WebViewHookHandler.java

示例4: stopAndStartVideos

import android.webkit.WebView; //導入方法依賴的package包/類
private void stopAndStartVideos(WebView oldView, WebView currentView){
    // Selects the first (and presumably only) video on the page if any exists
    String videoSelector = "document.getElementsByTagName('video')[0]";

    if(oldView != null)
        oldView.evaluateJavascript(videoSelector + ".pause();", null);
    if(currentView != null)
        currentView.evaluateJavascript(videoSelector + ".play();", null);
}
 
開發者ID:BloomBooks,項目名稱:BloomReader,代碼行數:10,代碼來源:ReaderActivity.java

示例5: invoke

import android.webkit.WebView; //導入方法依賴的package包/類
public void invoke(WebView webView, ValueCallback<String> callback) {
    if (webView == null)
        return;
    if (!mJsFuncSign.startsWith(JS_FUNC_PREFIX)) {
        mJsFuncSign = JS_FUNC_PREFIX + mJsFuncSign;
    }
    // api 19
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && callback != null) {
        webView.evaluateJavascript(mJsFuncSign, callback);
    } else {
        webView.loadUrl(mJsFuncSign);
    }
}
 
開發者ID:chendongMarch,項目名稱:uikit,代碼行數:14,代碼來源:JsFunction.java

示例6: onPageFinished

import android.webkit.WebView; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(@NonNull WebView view, String url) {
    if (view.isShown()) {
        mUIController.updateUrl(url, false);
        mUIController.setBackButtonEnabled(view.canGoBack());
        mUIController.setForwardButtonEnabled(view.canGoForward());
        view.postInvalidate();
    }
    if (view.getTitle() == null || view.getTitle().isEmpty()) {
        mLightningView.getTitleInfo().setTitle(mActivity.getString(R.string.untitled));
    } else {
        mLightningView.getTitleInfo().setTitle(view.getTitle());
    }
    if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT &&
        mLightningView.getInvertePage()) {
        view.evaluateJavascript(Constants.JAVASCRIPT_INVERT_PAGE, null);
    }
    mUIController.tabChanged(mLightningView);
}
 
開發者ID:XndroidDev,項目名稱:Xndroid,代碼行數:21,代碼來源:LightningWebClient.java

示例7: inject

import android.webkit.WebView; //導入方法依賴的package包/類
private void inject(WebView view, String script, ValueCallback<String> callback) {
    view.evaluateJavascript(script, callback);
}
 
開發者ID:hyb1996,項目名稱:Auto.js,代碼行數:4,代碼來源:InjectableWebClient.java

示例8: injection

import android.webkit.WebView; //導入方法依賴的package包/類
private void injection(WebView webView) {
//        Log.d("TTT_d", "injection - " + currVideoId);
        if (TextUtils.isEmpty(currVideoId) == true) {
            return;
        }

        if (Build.VERSION.SDK_INT >= 19) {
            webView.evaluateJavascript(rawJS, null);
        } else {
            webView.loadUrl("javascript:" + rawJS);
        }
    }
 
開發者ID:monthlypub,項目名稱:SmingZZick_App,代碼行數:13,代碼來源:YoutubeSmingActivity.java

示例9: evalJS

import android.webkit.WebView; //導入方法依賴的package包/類
/**
 * Evaluates JavaScript code in an API-level independent way.
 *
 * Note: all WebView methods must be called from the UIThread.
 */
@UiThread
static void evalJS(final WebView webView, final String script) {
    // implementation via http://stackoverflow.com/a/30828985/
    if (Build.VERSION.SDK_INT >= 19) {
        webView.evaluateJavascript(script, null);
    } else {
        webView.loadUrl("javascript:" + script);
    }
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:15,代碼來源:WebViewUtils.java

示例10: initWebView

import android.webkit.WebView; //導入方法依賴的package包/類
private void initWebView() {
        wvWeb = (WebView) findViewById(R.id.wv_web);
        wvWeb.setWebChromeClient(new WebChromeClient() {
            @Override
            public void onProgressChanged(WebView view, int newProgress) {
                super.onProgressChanged(view, newProgress);
                if (newProgress == 100) {
                    fl.setVisibility(View.GONE);
                    url = wvWeb.getUrl();
                } else {
                    fl.setVisibility(View.VISIBLE);
                }
            }
        });

        wvWeb.setWebViewClient(new WebViewClient());
        wvWeb.getSettings().setBuiltInZoomControls(false);
        wvWeb.getSettings().setJavaScriptEnabled(true);
        wvWeb.getSettings().setDomStorageEnabled(true);
        wvWeb.getSettings().setDatabaseEnabled(true);
//        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        wvWeb.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);  //設置 緩存模式
        String cacheDirPath = getFilesDir().getAbsolutePath();
        //      String cacheDirPath = getCacheDir().getAbsolutePath()+Constant.APP_DB_DIRNAME;
        //設置數據庫緩存路徑
        wvWeb.getSettings().setDatabasePath(cacheDirPath);
        //設置  Application Caches 緩存目錄
        wvWeb.getSettings().setAppCachePath(cacheDirPath);
        wvWeb.getSettings().setAppCacheEnabled(true);


        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
            Log.i("log", "initWebView: --------------  1");
            wvWeb.evaluateJavascript("document.body.style.backgroundColor=\"black\";document.body.style.color=\"white\";", null);
        } else {
            Log.i("log", "initWebView: --------------  2");
            wvWeb.loadUrl("javascript:document.body.style.backgroundColor=\"#black\";document.body.style.color=\"white\";");
        }
        wvWeb.loadUrl(url);



    }
 
開發者ID:lueans,項目名稱:LueansRead,代碼行數:44,代碼來源:WebActivity.java


注:本文中的android.webkit.WebView.evaluateJavascript方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。