Giacomo King Patermo
Giacomo King Patermo

Reputation: 849

Open link in same browser tab

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.

Upvotes: 2

Views: 2912

Answers (2)

stanleyxu2005
stanleyxu2005

Reputation: 8241

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.

Upvotes: 0

Rob Kennedy
Rob Kennedy

Reputation: 163287

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.

Upvotes: 8

Related Questions