Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

windows - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...