Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

WebBrowserControl Shortcuts Are Not Working (WinForms)

0.00/5 (No votes)
30 Oct 2015 1  
After upgrading from Internet Explorer 8 to Internet Explorer 11, WebBrowserControl shortcuts stopped working. After a lot of research, I found out the root cause of this and also a trick to resolve this issue.

Introduction

One fine day, I came across a strange issue that WebBrowserControl shortcuts were not working after I upgraded from Internet Explorer 8 to Internet Explorer 11.

I started Googling why shortcurts (ex: CTRL+C, CTRL+V) are not working. There were some suggestions saying overwrite the keypress event and write your own logic to handle the shortcuts. Overwriting keypress event may not be a bad idea. However, if we support 100 shortcuts, we need to write code to handle all of those.

After a lot of research, I finally found that this is a compatibility issue. Adding meta tag to the webbrowser control solves this problem.

I am sharing this experience so that if anyone faces the same issue, this trick will helps them.

Using the Code

Before navigating the URL, write meta into webbrowser's documenttext property as follows:

//Setting compatible mode of IE.
this.m_oWebBrowser.DocumentText = 
                  @"<html>
                  <head><meta http-equiv=""X-UA-Compatible"" 
                  content=""IE=IE11"" /> </head>
                  <body></body>
                  </html>";
this.m_oWebBrowser.Navigate(szURL);

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here