Page 1 of 1

How do I determine if the web content has loaded?

PostPosted: Wed May 11, 2022 7:59 am
by zhangyukun
Hello, I use the JCEF CefBrowser to invoke the CEF services, and use the swing display web content.
I want to use CefBrowser.executeJavaScript to call some JS operations after the page is loaded to close the pop-up windows.How do I determine if the web content has loaded?
Code: Select all
        String url = "https://blog.csdn.net/knighthood2001/article/details/124618877";

        JBCefBrowser myBrowser = new JBCefBrowser(url);
        CefBrowser cefBrowser = myBrowser.getCefBrowser();
      // After the web content is loaded
        cefBrowser.executeJavaScript("alert('hello world!');",cefBrowser.getURL(), 0);
        cefBrowser.executeJavaScript(
                "window.onload = document.querySelector('.open-app-weixin')?.click();",
                cefBrowser.getURL(), 0);
        basePane.add(myBrowser.getComponent(), BorderLayout.CENTER);

Re: How do I determine if the web content has loaded?

PostPosted: Thu May 12, 2022 7:40 am
by magreenblatt
Methods are provided by CefLoadHandler.