unexpected "script" error messages when using WebBrowser control in WinForms to navigate to CP sites
-
VS Version 16.8.6, Win 10, Chrome Version 88.0.4324.182 (Official Build) (64-bit) I was working on a response to a QA question: [^], and I reached in my code closet and pulled out an old example using the WebBrowser:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string url = @"https://www.codeproject.com";if (browserForm == null) throw new NullReferenceException(); if (! browserForm.Visible) browserForm.Show(); browserForm.TheWebBrowser.Navigate(url); linkLabel1.LinkVisited = true;}
This will trigger navigation to CP in the WebBrowser instance in a Form "owned" by the WinForm "main form." Several script errors will occur before a CP page, not the home page, is shown. Perhaps this is not an error ? An artifact of CP security ? cheers, Bill
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
-
VS Version 16.8.6, Win 10, Chrome Version 88.0.4324.182 (Official Build) (64-bit) I was working on a response to a QA question: [^], and I reached in my code closet and pulled out an old example using the WebBrowser:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string url = @"https://www.codeproject.com";if (browserForm == null) throw new NullReferenceException(); if (! browserForm.Visible) browserForm.Show(); browserForm.TheWebBrowser.Navigate(url); linkLabel1.LinkVisited = true;}
This will trigger navigation to CP in the WebBrowser instance in a Form "owned" by the WinForm "main form." Several script errors will occur before a CP page, not the home page, is shown. Perhaps this is not an error ? An artifact of CP security ? cheers, Bill
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
I assume you're aware that the WebBrowser control is stuck in IE7 mode by default, unless you modify the registry on every computer where your application runs? Web Browser Control & Specifying the IE Version - Rick Strahl's Web Log[^] I don't think it's unreasonable for modern sites to no longer support IE7 - it hasn't been updated in the last 11 years. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
I assume you're aware that the WebBrowser control is stuck in IE7 mode by default, unless you modify the registry on every computer where your application runs? Web Browser Control & Specifying the IE Version - Rick Strahl's Web Log[^] I don't think it's unreasonable for modern sites to no longer support IE7 - it hasn't been updated in the last 11 years. :)
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
thanks, Richard; fyi: using URL's of some other common sites results in correctly loaded web-pages; however, accessing StackOverflow exhibits similar script errors, and partial page loading where you can see a warning that the site does not accept Internet Explorer, but, does accept Edge, Chrome, etc. MSDN works okay; other sites that load properly come up in Thai probably because they can geo-locate me. i have a hazy memory of some content from MS suggesting the WinForm WebBrowser control has been updated in the last few years.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
-
thanks, Richard; fyi: using URL's of some other common sites results in correctly loaded web-pages; however, accessing StackOverflow exhibits similar script errors, and partial page loading where you can see a warning that the site does not accept Internet Explorer, but, does accept Edge, Chrome, etc. MSDN works okay; other sites that load properly come up in Thai probably because they can geo-locate me. i have a hazy memory of some content from MS suggesting the WinForm WebBrowser control has been updated in the last few years.
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
BillWoodruff wrote:
the WinForm WebBrowser control has been updated in the last few years
Not that I've seen. Unless you're thinking of the new
WebView2
control, which is based on Edge? Microsoft Edge WebView2 Control - Microsoft Edge Development | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
BillWoodruff wrote:
the WinForm WebBrowser control has been updated in the last few years
Not that I've seen. Unless you're thinking of the new
WebView2
control, which is based on Edge? Microsoft Edge WebView2 Control - Microsoft Edge Development | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Yes, that's what I am thinking of. As usual, the MS how-to for using it in Visual Studio WinForms omits the dependency on having Edge installed, and omits any mention of a work-around for the common failure [^] to get a non-null value for the CoreWebView2 object of the WebView that contains methods like Navigate. I hope you don't tell Redmond I uninstall Edge !
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
-
VS Version 16.8.6, Win 10, Chrome Version 88.0.4324.182 (Official Build) (64-bit) I was working on a response to a QA question: [^], and I reached in my code closet and pulled out an old example using the WebBrowser:
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string url = @"https://www.codeproject.com";if (browserForm == null) throw new NullReferenceException(); if (! browserForm.Visible) browserForm.Show(); browserForm.TheWebBrowser.Navigate(url); linkLabel1.LinkVisited = true;}
This will trigger navigation to CP in the WebBrowser instance in a Form "owned" by the WinForm "main form." Several script errors will occur before a CP page, not the home page, is shown. Perhaps this is not an error ? An artifact of CP security ? cheers, Bill
«One day it will have to be officially admitted that what we have christened reality is an even greater illusion than the world of dreams.» Salvador Dali
I'm guessing lots of those script errors will be ads, but there are sure to be some jQuery issues since we dropped IE support many, many moons ago. However, the site still works fine on my 2010 iPad!
cheers Chris Maunder