Closed ahgan84 closed 9 years ago
I have successfully solve the error by adding the below line to the "public Form1":
browser.IsBrowserInitializedChanged += new EventHandler
Seems like like this, it will only run IPXMLread() after the browser is initialized. But my browser still does not receive the "getIP()" function which I call using ExecuteScriptAsync(). Is it that the browser still does not initialized long time enough?
For the getIP() function in the webpage javascript, it is just like below:
<script>
getIP = function (IP1, Port1, IP2, Port2) {
alert("got it!!");
io_server_ip = IP1;
io_server_port = Port1;
iocon_server_ip = IP2;
iocon_server_port = Port2;
return false;
};
</script>
It can only received this function after sometime say, after the web page already load out for 5 seconds.
There are a limited number of functions you can perform once it's initialized, others you must wait for it to load. You need to use the LoadingStateChanged
handler to receive notifications of overall page load.
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.OffScreen.Example/Program.cs#L105 https://github.com/cefsharp/CefSharp/blob/master/CefSharp.OffScreen.Example/Program.cs#L71
Can I use this one?
browser.FrameLoadEnd += new EventHandler
browser.FrameLoadEnd += new EventHandler(IPXMLread);
In most cases you can. Remembering it will be called one for every frame, so if you have multiple frames.
For notification of overall browser load status use OnLoadingStateChange instead.
As per the documentation for OnLoadingStateChange
(Which translates to LoadingStateChanged
in CefSharp
). So as a general rule I reccomend using LoadingStateChange
.
Is it like this?
browser.LoadingStateChanged += new EventHandler
See the example I linked to before to get a rough idea of how it works.
https://github.com/cefsharp/CefSharp/blob/master/CefSharp.OffScreen.Example/Program.cs#L94
@ahgan84 Got it working? Anything else before closing?
Hi guys, How do we know whether the browser had been initialized? I want to put some data on the webpage immediately after it load out.
But there's an error saying that the browser is not initialized and I need to use the IsBrowserInitializedChanged event and checkthe IsBrowserInitialized property to determine when the browser has been intialized.
Is there any example that I can get regarding checking browser initializing? I search high and low but coudn't get it.