0

I've got web pages embeded into win forms app. For my purposes I use this web control. When new instance of browser is going to create, I handle NewWindow3 event and create new form with separate web browser control and pass it as ppDisp parameter. The problem I faced is that browser which is created from NewWindow3 event has document mode 5, lowest of all IE engines that I have on my machine. Can't understand why it's so and how can I fix it?

1 Answer 1

0

I've had exactly the same problem with the TEmbeddedWB component (extended version of the TWebbrowser VCL component) in Delphi 5 for a long time. I already did a lot of research in the past with no result. But today I found the solution after about 3 hours researching and trial&error. TEmbeddedWB has a public procedure "AssignEmptyDocument" with the following simple implementation:

procedure TEmbeddedWB.AssignEmptyDocument(bWait: Boolean = False);
begin
  Navigate('about:blank');
  if bWait then
    Wait;
end;

I have to execute this procedure BEFORE I assign the ppDisp. Here is my simplified solution in Delphi/Object pascal:

procedure Tfrm_browser.EmbeddedWBNewWindow3(ASender: TObject; var ppDisp: IDispatch;
  var Cancel: WordBool; dwFlags: Cardinal; const bstrUrlContext,
  bstrUrl: WideString);
var popup: Tfrm_popup;
begin   
  Application.CreateForm(Tfrm_popup, popup);
  popup.EmbeddedWB.AssignEmptyDocument;
  ppDisp := popup.EmbeddedWB.Application;
end;

In my case the documentMode of the popup is "9" afterwards, as expected. So, simply try to do a "Navigate('about:blank');" before assigning the ppDisp. In my case it works like a charm.

The reason for this behavior I don't know, sorry...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.