|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
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!
|
|
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/");
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
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.
|
|
Rank: Newbie Groups: Member
Joined: 4/12/2017 Posts: 5
|
Ok,I tried LoadHtml and redirects, It works, Thanks!
|
|