MyIHTMLDocument2:=(WebBrowser1.Document as mshtml.ihtmldocument2) ; for I := 0 to MyIHTMLDocument2.all.length-1 do begin MyElement:=MyIHTMLDocument2.all.item(i,i) as mshtml.IHTMLElement; if assigned(MyElement) then if uppercase(trim(MyElement.tagName))=uppercase('script') then begin MyElement.outerHTML:='';//1 //MyIHTMLDOMNode:= MyElement as mshtml.IHTMLDOMNode ; //MyIHTMLDOMNode.parentNode.removeChild(MyIHTMLDOMNode) ;//2 end; end; 分别使用方法1 和2 都不行,请教大侠们怎么搞呢?
可我查看别人的,似乎也是类似这么操作的啊:
void RemoveChildNode() { var document = webBrowser1.Document.DomDocument as HTMLDocument;
if (document != null) { var childNode = document.getElementById("child") as IHTMLDOMNode;
if (childNode != null) { var parentNode = childNode.parentNode;