Search code examples
cefsharp

How to Act as Internet Explorer


I am using cefsharp in windows forms application. Somehow some sites need to run on internet explorer only. How can we set cefsharp (chromium) act like internet explorer?

I changed request headers to set user-agent like "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)" bu it did not solve my problem. The site still gets that the browser is not IE.

Could you please provide a solution?

Thanks for further help


Solution

  • I found the solution as faking the site like adding missing property/funcs to document object in frameloadstart event like this.

            private void Browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e)
        {
            browser.EvaluateScriptAsync(@"if(!document.all) { document.all = {};}  if(!document.compatMode) { document.compatMode = 'BackCompat'} if(!document.getElementsByTagName){ document.getElementsByTagName = function(){}; } ");
        }