1

How do I open a link in the same browser tab? I tried this code:

ShellExecute(Handle, 'open', 'http://site.com', '_self', nil, SW_SHOWNORMAL);

But it continues to open the link in a new table.

Thanks.

Giacomo King Patermo
  • 829
  • 3
  • 13
  • 25
  • I'm trying to understand do you mean a new tab in your own web browser application using a `TWebBrowser` or do you mean a new tab in whatever default web browser is there? I'm assuming the second... Also, what do you mean by a "new table"? – Jerry Dodge Jun 18 '12 at 23:49

2 Answers2

7

I've written on this topic before:

ShellExecute has absolutely no notion of "tab." In fact, it doesn't even have a notion of "default browser." All it does is find whatever program is configured for file names that start with "http://" and execute the configured command line.

What the browser does with the new command line is its own choice. The API function has no control. Sometimes, the browser allows the user to configure it.

Opening a new tab or window is the safest thing to do. Neither you nor the browser knows whether the user is still using the previous tab or window.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
0

A possible entry point is using OLE Automation. Using this technique you can connect with any existing instance of MSIE, so that you can bring the current browsing window to a new url.

stanleyxu2005
  • 8,081
  • 14
  • 59
  • 94