0

I want to open url in already existing, active opera/IE/FF tab using delphi.

I tried:

ShellExecute(hw,'open',pchar(url),nil,nil,SW_SHOWNORMAL);

where hw is handle of web browser and url is string variable with url I want to open, but it opens new tab instead of using active tab.

I also tried:

procedure SetURL(Browser, URL: String);
var
  Client_DDE: TDDEClientConv;
begin
  Client_DDE := TDdeClientConv.Create(nil);
  with Client_DDE do
  begin
    SetLink( Browser, 'WWW_Activate' );
    RequestData('0xFFFFFFFF');
    SetLink( Browser, 'WWW_OpenURL' );
    RequestData(URL);
    CloseLink;
  end;
  Client_DDE.Free;
end;

And SetURL('Opera', url); in buttonclick procedure, but it also opens url in new tab. When I use RequestData(URL + ',-1'); in SetURL procedure then it opens url in new window. Any ideas how to open url in already existing browser tab?

I have Delphi 7.

  • 1
    possible duplicate of [Open link in same browser tab](http://stackoverflow.com/questions/11087969/open-link-in-same-browser-tab). DDE only works if the hosting application has specifically been written to respond to commands, and it's highly unlikely that all browsers will support DDE (especially since it's a MS technology), and even more unlikely that the few that do will have a handler for `WWW_` commands specifically. You're barking up the wrong tree on all counts here. :-) – Ken White Oct 18 '13 at 18:34

1 Answers1

0

Unfortunately, that isn't possible. Take a look at similar question: Open link in same browser tab

Community
  • 1
  • 1
Srđan Tot
  • 235
  • 2
  • 7
  • I read that topic, now I know that I can't do it by ShellExecute and SetUrl, but is there any other way? stanley wrote something about "OLE Automation", can you, please, give me code sample or link to information about "OLE Automation"? –  Oct 18 '13 at 20:43
  • AFAIK only Internet Explorer supports OLE autimation. I have never used IE like that, so I can't help you more than this. Your best bet for now is to search web for "Internet Explorer OLE Automation". – Srđan Tot Oct 18 '13 at 21:15
  • And what about other web browsers for example Opera? –  Oct 19 '13 at 10:36
  • OLE is Microsoft Windows feature, it isn't supported on other operation systems, so except Internet Explorer, browsers don't support OLE. – Srđan Tot Oct 19 '13 at 11:06
  • I understood it, but then how can I work with other browsers? Is there any other way to open url in the same tab? –  Oct 19 '13 at 11:26
  • 1
    As I wrote in answer, that isn't possible. Browsers don't expose functions for that kind of behaviour when opening urls. – Srđan Tot Oct 19 '13 at 11:41