I am opening different browsers using
ProcessStartInfo startBrowser = new ProcessStartInfo(internetbrowser, website);
Process.Start(startBrowser);
Which works great. However, I need to also know when the webpage has loaded. Is there a way that I can check this? Or even better, fire an event when the page is fully loaded?
Thanks
You didn't noticed in your question which browser you want to use.
If you use the Internet Explorer
than I have a good solution. You need a reference to the SHDocVw.dll
for the example below.
Tested code example:
private void Form1_Load(object sender, EventArgs e)
{
InternetExplorer explorer = new InternetExplorer();
object Empty = 0;
object URL = "http://www.yourwebsite.com"; // Here your URL
// There are many more events.. But we need this one:
explorer.DocumentComplete += ExplorerOnDocumentComplete;
explorer.Visible = true; // If you wish to see the IE, set it to true.
// Navigate to the provided URL
explorer.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);
}
private void ExplorerOnDocumentComplete(object pDisp, ref object url)
{
// The document loaded completly.
// Do your work here.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.