How to hide HtmlElement in webbrowser control

Deadly 提交于 2019-12-03 09:22:22
Codeffect

Try making an html file that contain the script :

function SetHidden()
  {
   window.document.all["hiddenText"].style.display="block";
   return "ok";
  }

After that place in your C# code :

Results = (string)WebBrowser1.Document.InvokeScript("SetHidden");

MessageBox.Show(Results);

I think i am late.but it may help somebody who need it. You can change the outerhtml of that specific image at run time.Like that

myDoc = this.webBrowser1.Document;

myDoc.GetElementById("imgToHide").OuterHtml = "Changed html here!";

You can use runtimeStyle

IHTMLElement2 domElement = element.DomElement as IHTMLElement2;
domInspectBox.runtimeStyle.visibility ="hidden"; // if you want to hide it
domInspectBox.runtimeStyle.display = "none"; // if you want to empty its place
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!