vinnitu
vinnitu

Reputation: 4364

what is IWebBrowser::Navigate2 equivalent for window.open(...)?

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

Answers (2)

KAdot
KAdot

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

Nathan Moinvaziri
Nathan Moinvaziri

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

Related Questions