Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Windows.Forms.WebBrowser control Document.Window.Error does not fire when document contains X-UA-Compatible IE=edge meta tag.

$
0
0

Like the title states. I'm using WebBrowser control. I need to capture JavaScript errors. I have the following HTML in a document I'm trying to load as an example:

<html><head><meta http-equiv="X-UA-Compatible" content="IE=edge"><script>
    	alert("hi;</script></head><body></body></html>

Note that JavaScript alert is wrong and throws JavaScript exceptions. Also note that when meta tag is absent, or set to IE=9 my code works. When present, it doesn't. Here's the sample code in C#

var browser = new WebBrowser();
browser.Dock = DockStyle.Fill;

browser.Navigated += (s,a) => {
        browser.Document.Window.Error += (sender, args) => {
		MessageBox.Show("Error:  " + args.Description);
		args.Handled = true;
	};

};

browser.Navigate("http://localhost/sample.html");
What's going on here? What can I do to make it work with 10+?


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>