views:

167

answers:

1

I am using below code to inject javascript

HtmlElement head = _wb.Document.GetElementsByTagName("head")[0];
            HtmlElement scriptEl = _wb.Document.CreateElement("script"); 
            mshtml.IHTMLScriptElement element = (mshtml.IHTMLScriptElement)scriptEl.DomElement; 
                        element.text = "function zoom(){document.body.style.zoom='150%';}"; 
            head.AppendChild(scriptEl);

Now can anyone tell me how to remove the added child

A: 

I think explicit deleting of an element is not possible (did not check the IHTML interfaces on this). But this can be done in 2 different ways too: 1) element.OutherHtml = string.empty; => removes the whole element but does not always work 2) HtmlElement blankScript = _wb.Document.CreateElement("script"); element = blankScript; => replaces your unwanted script with a blank one

Greets, Daniel

SBS_Daniel