Welcome Guest Search | Active Topics | Sign In | Register

How to create a global Loading to avoid white screen Options
CaiHua
Posted: Friday, April 14, 2023 2:46:33 AM
Rank: Newbie
Groups: Member

Joined: 4/12/2017
Posts: 5
Some pages load very slowly and cause a white screen in the webview.
How to create a Loading (using css or js of local projects) when WebView opens the page.

WebView.JSInitCode can only execute js



eo_support
Posted: Friday, April 14, 2023 10:48:31 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

You will need to do this inside your web page, not on the WebView. For example, some page only contains a small "loader" JavaScript that can load very quickly. That JavaScript code will then display some "loading..." UI message and then load the actual content from server. Another strategy that is often used by complex page is to only load a small portion of the page, then load more contents as user scrolls. For example, facebook may only load one screen of messages when you initially load the page, but then as user scrolls down it will load more.

The point is whatever strategy you use, it is done inside the page and has to do with the contents/server of the page. So this is not something done on the WebView level.

Thanks!

CaiHua
Posted: Monday, April 17, 2023 2:05:21 AM
Rank: Newbie
Groups: Member

Joined: 4/12/2017
Posts: 5
We may open different system pages, some developed by ourselves and some developed by others. It is impossible to require all system pages to add loading by themselves. The white screen is caused by slow network requests. So the best way is to load a loading on the webview first.

I tried writing a loading div like below before loading the url. it seems works. but if I put the code in the Form1_Load,It will fail with the error message "EO.WebBrowser.WebView.GetDOMWindow(...) returned null."

webView.GetDOMWindow().document.body.innerHTML = "<div>Loading...</div>";
webView.LoadUrl("https://www.essentialobjects.com/");
eo_support
Posted: Tuesday, April 18, 2023 9:49:13 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
This is why we were telling you that you need to do it INSIDE the page. Note the page does not have to be the real page you are trying to load. For example, you can construct a small piece of HTML that contains the "Loading..." message first and also some JavaScript code that redirects to the actual page you are trying to load. You would then call WebView.LoadHtml to load that HTML instead calling LoadUrl to load the actual Url. The key is whatever you need to do you need to do it inside the page with HTML/JavaScript.
CaiHua
Posted: Tuesday, April 18, 2023 9:11:24 PM
Rank: Newbie
Groups: Member

Joined: 4/12/2017
Posts: 5
Ok,I tried LoadHtml and redirects, It works, Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.