views:

112

answers:

1

I am working on a Windows desktop app (C++) that has an embedded Internet Explorer page. I'm working on the html page that is displayed in the There is not a back button control, so one of the requests is that links clicked on in the page should open the link in a browser window. It can open the link in the users default browser or in IE.

Is this possible? I realize that this is not possible because javascript is in a sandbox and cannot touch outside applications. I'm thinking there might be a way because it is using the IE.

I have tried the two methods that have worked for me in the past. Using jquery, I've tried these two approaches, but neither work in the app. They both work fine in normal browsers.

Using target="_blank"

 $( "a" ).attr( "target", "_blank" );

The other is using window.open:

 $( "a" ).click( function() {
   window.open( $( this ).attr( "href" ) );
 } );

I'm afraid that writing windows desktop applications is outside my area of expertise, so I cannot give more information regarding that side of the issue.

A: 

Look for the BeforeNavigate2 event that the browser will fire. You can use that to grab the URL that they're headed to, and the cancel the navigation (so your browser won't actually leave the page it's on).

Then, once you have the URL, just execute:

ShellExecute(GetSafeHwnd(), _T("open"), m_url, _T(""), _T(""), SW_SHOW);
DougN