Reputation: 4364
i need equivalent for
window.open('url to open','window name','toolbar=no');
in c#, or C++ - no metter
Thanks for any help
Upvotes: 0
Views: 755
Reputation: 2077
Simply use IHTMLWindow2::open.
BOOL OpenWindow(IWebBrowser2* pWebBrowser, CString strUrl, CString strName, CString strFeatures)
{
if(pWebBrowser != NULL)
{
CComDispatchDriver pDocDisp;
if(SUCCEEDED(pWebBrowser->get_Document(&pDocDisp)))
{
CComQIPtr<IHTMLDocument2> pDoc = pDocDisp;
if(pDoc != NULL)
{
CComPtr<IHTMLWindow2> pWindow;
if(SUCCEEDED(pDoc->get_parentWindow(&pWindow)))
{
CComPtr<IHTMLWindow2> pWindowResult;
return SUCCEEDED(pWindow->open(CComBSTR(strUrl), CComBSTR(strName), CComBSTR(strFeatures), VARIANT_FALSE, &pWindowResult));
}
}
}
}
return FALSE;
}
Upvotes: 2
Reputation: 5638
If you have a pointer to the IWebBrowser2
interface, you can call IWebBrowser2::get_document
and retrieve the IDispatch
interface. You can then query it for IHTMLDocument2
. Once you have that call IHtmlDocument2::get_parentWindow
. From the IHTMLWindow2
interface that is returned you can call IHTMLWindow2::execScript
and you can pass in your javascript directly to that function and have it executed.
Upvotes: 1