This Event handler returns:
System.Runtime.InteropServices.COMException: 'Unknown name. (Exception from HRESULT: 0x80020006 (DISP_E_UNKNOWNNAME))'
Code:
private void Browser_Loaded(object sender, NavigationEventArgs e)
{
browser.InvokeScript("Document.Body.Style =" + "zoom:80%");
}
i have tried many solutions found online, but none seem to work for me please advise
Try this
private void Browser_Loaded(object sender, NavigationEventArgs e)
{
var zoom = 0.8;
mshtml.IHTMLDocument2 doc = browser.Document as mshtml.IHTMLDocument2;
doc.parentWindow.execScript("document.body.style.zoom=" + zoom.ToString().Replace(",", ".") + ";");
}
Its working for me.
Don't forget to reference Microsoft.mshtml
References:
User contributions licensed under CC BY-SA 3.0