Reputation: 581
I made some LinkLabels on my Form, they are the link for each chapter of a eBook. According to that, I wanted to navigate on my WebBrowser using that labels but the browser isn't navigating not even for a legit Uri like "www.google.com".
If I click on the links displayed on my document from the browser, it will go to the right section, otherwise it will not move...
I have tried this link How can I navigate a webbrowser programmatically? but I didnt worked for me.
So, this is my code:
private void createBrowser()
{
wb = new WebBrowser();
wb.ScrollBarsEnabled = true;
showText.Controls.Add(wb);
wb.SetBounds(0, 0, showText.Width, showText.Height);
wb.DocumentText = epub.GetContentAsHtml();
}
private void linkedlabel_click(object sender, LinkLabelLinkClickedEventArgs e) {
// none of this worked...
// wb.Navigate(e.Link.LinkData.ToString());
// wb.Document.All[e.Link.LinkData.ToString()].InvokeMember("click");
}
I tried to add some navigating listeners but nothing... My e.Link.LinkData.toString() returns the the pages, like "0001.html", "0002.html", etc.
Upvotes: 0
Views: 1366
Reputation: 139
After create the WebBrowser with Visual Studio, check if your URL is correct. I mean, If the page 0001.html is in your desktop ensure to use the complete direction. Example:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
//If your website is on the startup path
webBrowser1.Navigate(Application.StartupPath + "\\0001.html");
//OR
//If your website is on the internet
webBrowser1.Navigate("http://www.website.com/0001.html");
}
Upvotes: 1