Welcome Guest Search | Active Topics | Sign In | Register

web browser event Options
yleung
Posted: Tuesday, April 22, 2014 7:27:21 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Hi,

I am working on a project that replace System.Windows.Forms.WebBrowser with EO.WebBrowser.WinForm.WebControl.

System.Windows.Forms.WebBrowser has DocumentCompleted, Navigated, Navigating event. Are these event available in EO.WebBrowser.WinForm.WebControl? I found WebView.LoadComplete but I am not sure.

Thanks
Howie
eo_support
Posted: Tuesday, April 22, 2014 8:08:41 PM
Rank: Administration
Groups: Administration

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

Yes. WebBrowser has events that provide the equivalent features but are in different names and do not have a one to one relationship with the MS version. The related events on WebBrowser are IsLoadingChanged, BeforeNavigate, UrlChanged. BeforeNavigate is similar to Navigating, UrlChanged is similar to Navigated. IsLoadingChanged can be used to see if the WebBrowser is currently loading a document or is sitting idle.

LoadComplete event is something slightly different --- it is only fired for Urls loaded with one of the LoadXXX function. For example, you can use LoadUrl to load an Url and then wait for the corresponding LoadComplete event. LoadComplete event does not if you just click a link in a page and navigate to another page (Both BeforeNavigate and UrlChanged will be fired for this case).

Thanks!
yleung
Posted: Friday, May 2, 2014 4:11:20 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Thanks for the help!

I have replaced System.Windows.Forms.WebBrowser with EO.WebBrowser.WinForm.WebControl in my application. However, UrlChanged and IsLoadingChanged event sometimes are not fired. I think it is because my co-worker have some complicated logic in BeforeNavigate event that set the browser's Visible property to false, resize the browser, or changing the zoomfactor. I have been fighting for this problem for 2 full days. Could you help me to identify the potential problems? What should I avoid to do in BeforeNavigate event?
eo_support
Posted: Friday, May 2, 2014 4:22:40 PM
Rank: Administration
Groups: Administration

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

Based on what we know resizing or changing zoom factor should not matter, however setting the Browser's Visible to false most likely could have an impact. Is it possible for you to create a test app that demonstrates the problem and then send the test app to us? Once we have that we will try to run it here. Usually as soon as we can see the problem, we will be able to find out the root cause.

Thanks!
yleung
Posted: Tuesday, May 6, 2014 9:52:20 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Thanks for the help!

I spent another 2 days on this problem. 4 days in totally but still cannot find out how come UrlChanged and IsLoadingChanged event sometimes are not fired.

I write a recursive function to add ParentChanged visibleChanged event handler to track if the browser control, parent control, or grand parent control, etc are removed from UI or visible is changed. The conclusion is, after BeforeNavigate event is raise, their visible and parent are not changed .

I also made sure that WebControl constructor is only called once and never dispose after that.

Our code never remove UrlChanged and IsLoadingChanged event handler from the webbrowser.

Can you help me to brainstorm any reasons why UrlChanged and IsLoadingChanged are not fired?

Sorry that I don't know how to create sample code. It only happens on my application, and I cannot give you the source code due to my company policy.

Thanks for the help.
eo_support
Posted: Thursday, May 8, 2014 12:58:55 AM
Rank: Administration
Groups: Administration

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

You would have to create a sample app for such cases. The fact that it only happens in your app means exactly that it has something to do with your specific logic. We can't guess out that logic in dark. That's why you have to create a sample app for us. Please keep in mind that we do not want the source code of your application even if your company's policy allows it. We are not in a position to debug or troubleshoot problems in your application for free even if the problem arises from using our product. So you will have to isolate the problem first.

Thanks!
yleung
Posted: Thursday, May 8, 2014 1:00:17 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Agree.. I have the responsibility to minimize the code to show you the problem. That's why I work on this problem for 4 days before asking you to guess. Anyway. I resolved the problem. I now dispose and recreate an instance of the webcontrol whenever I need to call loadURL. I don't know why I need to do this, but it works.

Thanks for the help.
eo_support
Posted: Thursday, May 8, 2014 5:10:11 PM
Rank: Administration
Groups: Administration

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

I am glad to hear that its working for you. That's probably not the best way to do it since you are creating and disposing the WebControl instance way too often. In any case, if you have a sample app please feel free to send it to us. We will look into it immediately as soon as we have it.

Thanks!
yleung
Posted: Wednesday, June 4, 2014 6:46:34 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Dear support,

After calling LoadURL() for the web browser control, I need to update a status message on a label control.
When BeforeNavigate is raised, I set the status message to be "Waiting for server response".
When IsLoadingChanged is raised and WebView.IsLoading is False, I set the status message to be "Done".
Between showing "Waiting for server response" and "Done", I want to show a status message, "Rendering..." Which event should I used? This event should be raised when the web browser is going to render the page content.

Thanks
Yuenho
eo_support
Posted: Wednesday, June 4, 2014 10:09:40 PM
Rank: Administration
Groups: Administration

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

You won't be able to do that. There is no event that tells you when the browser is rendering the page and rendering is probably the most complicated part of the browser engine. The rendering does not necessarily to be done in one pass and it can happen at ANY stage of loading process. For example, if the browser has loaded a part of the HTML but is still waiting for some images to finish loading, it would try to render the part of HTML that it has already received ---- it will just do the layout again when fill in the image when it later receives the image. The same thing happens to CSS. If your page references an external CSS file, the browser can render the main HTML before that CSS file is received and then render it again to produce a more accurate rendering after that CSS file is received. To make the matter even more complicated, rendering is done completely asynchronously, both against the loader/parser, and inside the GPU pipeline. So it's not as simple as Loading -> Rendering - Done. Because of this reason the event you were looking for would not exist.

Thanks!
yleung
Posted: Thursday, June 5, 2014 1:59:26 PM
Rank: Advanced Member
Groups: Member

Joined: 4/2/2014
Posts: 37
Thanks for the reply!

What you said make lot of sense. All I want is an event that is raised between BeforeNavigate and IsLoadingChanged. I thought about UrlChanged, but this event is raised only if the browser tries to load a different page. If it just reloads the current page, it is not called so I cannot use this event.

If you don't have any event that is always raised between BeforeNavigate and IsLoadingChanged, could you help me from a different direction?

When I call LoadUrl, I want to do ensure UrlChanged event is always raised. Calling LoadUrl to reload the same url will not raise this event. To resolve this problem, I try to called LoadHTML("", "about:blank") to first navigate to a blank page before I call LoadUrl. But this doesn't trigger UrlChanged. Any suggestion?

Thanks
Yuenho
eo_support
Posted: Thursday, June 5, 2014 4:33:34 PM
Rank: Administration
Groups: Administration

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

You MAYBE able to use BeforeRequestLoad event. That event is fired before every request is loaded.

LoadHtml does not change the current url. In a way it's similar to document.body.innerTHML = new_html. If you want to force change, you will need to use LoadUrl. You can use data Url. For example, you can use code like this:

Code: C#
LoadUrl("data:text/html;charset=utf-8,some_invisible_html");


Please let us know if it works for you.

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.