I am trying to load a certain page though WebBrowser control while avoiding unnecessary advertisement banners which load in DIV element called ‘tb’.
How can I do this? I have done some googling and found an example using mshtml reference but I can’t make it work from this example: https://stackoverflow.com/a/1218875
Any ideas?
Why wouldn’t this work?
using System;
using mshtml;
using System.Windows.Forms;
namespace Client
{
public partial class Client : Form
{
public Client()
{
InitializeComponent();
HTMLDocumentClass htmldoc = wbBrowser.Document.DomDocument as HTMLDocumentClass;
IHTMLDOMNode node = htmldoc.getElementById("tb") as IHTMLDOMNode;
node.parentNode.removeChild(node);
}
}
}
I get an error:
‘mshtml.HTMLDocumentClass’ does not contain a definition for ‘getElementById’ and no extension method ‘getElementById’ accepting a first argument of type ‘mshtml.HTMLDocumentClass’ could be found (are you missing a using directive or an assembly reference?)
And:
Interop type ‘mshtml.HTMLDocumentClass’ cannot be embedded. Use the applicable interface instead.
You can do this using: