Si-Chang Hyun

Hi,

I programmed test program that navigate url with "Navigate()" method of BHO (Browser Helper Object).

And, I saw the url page successfully.

But, some page is wrong.

In example, "sign in" page in this site:

- Some frames in the page have scroll bar.

- Login procedure is failed.

(Without my BHO code, the original page has no scroll bar, and login procedure is good.)

My test code is very simple as follows:

This method "OnBeforeNavigate2()" is called when the event "DISPID_BEFORENAVIGATE2" is received in the method "Invoke()".

======= start of code =======

BOOL CSWATHelper::OnBeforeNavigate2(DISPID dispid, REFIID riid, LCID lcid, WORD flags, DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep, UINT *argerr)

{

USES_CONVERSION;

HRESULT hr = S_FALSE;

CComPtr<IWebBrowser2> spBrowser;

CComPtr<IDispatch> spDisp = ((*params).rgvarg)[ 6 ].pdispVal;

hr = spDisp->QueryInterface(IID_IWebBrowser2,(void**)&spBrowser);

if (hr != S_OK) {

return TRUE;

}

// Variable "bSentAlrady" is flag to prevent infinite loop.

// If it is "TRUE", then this event is caused from the below "spBrowser->Navigate()" method.

// So, in this time, just return.

if (bSentAlready != FALSE) {

bSentAlready = FALSE;

return TRUE;

}

// Stop navigate.

spBrowser->Stop();

// Set the flag to "TRUE" for preventing infinite loop.

bSentAlready = TRUE;

// navigate to original url (for just test).

spBrowser->Navigate((*params).rgvarg[ 5 ].pvarVal->bstrVal, NULL, NULL, NULL, NULL);

return FALSE;

}

======= end of code ========

The above method is called when the event "DISPID_BEFORENAVIGATE2" is received.

And, it is just navigate to original url. It looks like very simple.

What' the matter What should I do

I spent several months on the above problem.

I really appreciate any one advice me.

Regards

Hyun.




Re: Internet Explorer Extension Development How to navigate url with BHO?

Reza Nourai - MSFT

The URL you are trying to navigate to may have some dependencies on the post data and headers being passed (most likely this is the reason your login is failing).

So, you should inspect (*params).rgvarg[0-4] and pass those back into your Navigate call.

-Reza





Re: Internet Explorer Extension Development How to navigate url with BHO?

Si-Chang Hyun

Thanks Reza.

I try again as your advice with the below code:

spBrowser->Navigate((*params).rgvarg[5].pvarVal->bstrVal, (*params).rgvarg[4].pvarVal, (*params).rgvarg[3].pvarVal, (*params).rgvarg[2].pvarVal, (*params).rgvarg[1].pvarVal);

So, I'm success to login in this forum login page.

But, in some login pages in other site, login procedure is also failed.

And, in the list page of this forum site, "Search" function does not doing well.

Even now, the additonal scroll bar is displayed.

Is there anything wrong in the above code

Is there anything I should do

Regards,

Hyun.






Re: Internet Explorer Extension Development How to navigate url with BHO?

John Sudds - MSFT

The BeforeNavigate2 event defines its own way of canceling the event. You must cancel the event in progress by returning TRUE in the Cancel parameter.

You should not use the Stop method of the WebBrowser control.

Refer to the code example under Controlling Navigation on this page:
http://msdn2.microsoft.com/en-us/library/Aa770041.aspx

Code Snippet

// Set Cancel parameter to TRUE to cancel the current event

*((pDispParams->rgvarg)[0].pboolVal) = VARIANT_TRUE;


Hope that helps.





Re: Internet Explorer Extension Development How to navigate url with BHO?

Si-Chang Hyun

Thanks John.

I have tested with the below code:

*V_BOOLREF(params->rgvarg + 0) = VARIANT_TRUE;

But, I can't get the result I expected.

I saw the article which Reza Nourai has written at the below link:

https://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1200447&SiteID=1

In the article in the above link, Reza said as follows:

if (URL == SomeUrlWeWantToBlock)

{

*cancel = true;

}

An example that Redirects could look like:

if (URL == SomeUrlWeWantToRedirect)

{

CComQIPtr<IWebBrowser2,IID_IWebBrowser2> spBrowser = pDisp;

spBrowser->Stop();

spBrowser->Navigate2( NewUrl, ... );

}

I don't want to block the specific site.

I just want to navigate same site with

- adding some header information, or

- changing the query data of "GET" method to post data of "POST" method.

So, I have used Stop() method.

And, I have also canceled the parameter like as the above.

But, I can't get the expected result with the above two cases.

Since the almost one month, I have searched the solution. But, I can't till now.

Please, help me.

Is there anybody to show the sample code or advice

Regards,

Hyun.