Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addJavaScriptInterface problem #28

Open
Jichzhang opened this issue Dec 15, 2020 · 1 comment
Open

addJavaScriptInterface problem #28

Jichzhang opened this issue Dec 15, 2020 · 1 comment

Comments

@Jichzhang
Copy link

hi mr ks32

when i use “addJavaScriptInterface” add a interface for my js code then i used the interface like this “window.Android.funtionName”
the will tell me “Uncaught TypeError: window.Android.funtionName is not a function”

@SuppressLint({"SetJavaScriptEnabled"})
    private void initWebView(){
        XWalkSettings webSettings = this.webView.getSettings();
        webSettings.setLoadsImagesAutomatically(true);
        webSettings.setSupportSpatialNavigation(true);
        webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        webSettings.setDomStorageEnabled(true);
        XWalkPreferences.setValue("remote-debugging", true);
        webSettings.setAllowFileAccess(true);
        webSettings.setAllowFileAccessFromFileURLs(true);
        webSettings.setAllowUniversalAccessFromFileURLs(true);
        webSettings.setAllowContentAccess(true);
        webSettings.setAppCacheEnabled(true);
        webSettings.setFullscreenSupported(true);
        this.uiClient=new XwalkClientEXT(this,this.webView);
        this.webView.setResourceClient(new XWalkResourceClient(){
            @Override
            public void onLoadFinished(XWalkView view, String url) {
                super.onLoadFinished(view, url);
                setImmersiveMode();
            }
        });
        this.webView.setUIClient(this.uiClient);
        this.webView.clearCache(true);
        this.webView.requestFocus(130);
        this.webView.addJavascriptInterface(new JavaScriptInterface(this),"Android");
        CookieManager.getInstance().setAcceptCookie(true);
        CookieManager.setAcceptFileSchemeCookies(true);
        ((FrameLayout)findViewById(R.id.webview)).addView(this.webView);
    }

@JavascriptInterface
    public String io_sb3FileExists(String file) { return "";}
if("true"==window.Android.io_sb3FileExists(fileName)){}
@yyfd2013zy
Copy link

hi,Have you solved this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants