Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Disabling JavaScript error messages in webbrowser control

$
0
0

We are using webbrowser control display the content. While loading the content first time it display an error message.

Error message

“You are currently runninginternet explorer7, which is not supported by….”

Observations

1. Webpage supported browser details.

2.Above mentioned error display in webbrowser control 1<sup>st</sup> time but when we try to load the same content again it will not display such type of error message.

3. To replicate the issue, Go to internet options – Delete browsing History - clear cookie and reload page via webbrowser control.

4. There is no property on the browser control which can be used to suppress this kind of error.

6. The page which we are trying to view is not maintained by us.

5. Code snippet to suppress such error message first time.

string DisableScriptError =

              @"function noError() {

                          return true;

                        }  

              window.onerror = noError;";

var doc = (HTMLDocument)webInfoViewer.Document;

var head = doc.getElementsByTagName("head").Cast<HTMLHeadElement>().First();

var script = (IHTMLScriptElement)doc.createElement("script");

//script.text = "document.getElementById('messagearea').style.display = 'none';";

//script.text = DisableScriptError;

//script.text = "alert('hello')";

script.text ="window.onerror = true;";

head.appendChild((IHTMLDOMNode)script);

It's wpf webbrowser


Viewing all articles
Browse latest Browse all 3527

Trending Articles