I\'m completely new to developing IE extensions with Browser Helper Objects.
I managed to create a BHO that successfully inserts a script tag that references a javascri
You should use execScript instead of appendChild. And the syntax of what you need to exec is very, very wierd. But it accomplishes what you want -- namely, an external JavaScript is added to the DOM. Call this during OnDocumentComplete:
VARIANT vrt = {0};
CComQIPtr<IHTMLWindow2> win;
spHTMLDoc->get_parentWindow(&win);
CComBSTR bstrScript = L"var html_doc = document.getElementsByTagName('head')[0]; var _js = document.createElement('script'); _js.setAttribute('type', 'text/javascript'); _js.setAttribute('id', 'bho_js'); _js.setAttribute('src', 'http://domain.com/script.js'); if(!document.getElementById('bho_js')) html_doc.appendChild(_js);";
CComBSTR bstrLanguage = L"javascript";
HRESULT hrexec = win->execScript(bstrScript,bstrLanguage, &vrt);
This will add <script type="text/javascript" id="bho_js" src="http://domain.com/script.js"></script>
into the DOM HEAD.