简体   繁体   English

如何以编程方式更改浏览器 URL

[英]How to programmatically change browser URL

In my C++ Windows application I use ShellExecute to open a remote PDF file in the internet browser at a certain PDF Destination (dynamic bookmarks provided by Adobe Acrobat Reader): In my C++ Windows application I use ShellExecute to open a remote PDF file in the internet browser at a certain PDF Destination (dynamic bookmarks provided by Adobe Acrobat Reader):

ShellExecute(NULL, "open", "https://www.myweb.cloud/guide.pdf#dest_1", NULL , NULL, SW_SHOWNORMAL);

Then if I want to move to another Destination, another call to ShellExecute (with #dest_2 in the URL) simply open another page in the browser and download the PDF again opening it at that Destination.然后,如果我想移动到另一个目的地,对 ShellExecute 的另一个调用(在 URL 中带有#dest_2)只需在浏览器中打开另一个页面并下载 PDF 再次在该目的地打开它。

Is there a way to programmatically change the URL (from #dest_1 to #dest_2) without making the browser to open a new page e re-dowload the PDF?有没有办法以编程方式更改 URL(从 #dest_1 到 #dest_2)而不使浏览器打开新页面并重新下载 PDF?

I also use LibCurl in my application in order to retrieve data from remote servers.我还在我的应用程序中使用 LibCurl 来从远程服务器检索数据。 Can I reach my goal with LibCurl?我可以用 LibCurl 实现我的目标吗? If so, could you plese show me a code sample?如果是这样,你能给我看一个代码示例吗?

Thanks in advance.提前致谢。

  1. External links opened with ShellExecute are always opened in a new tab by default.默认情况下,使用ShellExecute打开的外部链接始终在新选项卡中打开。 Chrome can't change this behavior. Chrome 无法更改此行为。 Early Firefox had an option for opening an external link in a currently active tab, but does not seem to have it now.早期的 Firefox 有一个在当前活动选项卡中打开外部链接的选项,但现在似乎没有。
  2. You can download files with libcurl, see url2file example.您可以使用 libcurl 下载文件,请参阅url2file示例。 After a file has been downloaded, you can open it in a certain application with ShellExecute .下载文件后,您可以使用ShellExecute在某个应用程序中打开它。 You just need to find an application, that is suitable to your requirements.您只需要找到适合您要求的应用程序。 For example Adobe Reader does not seem to support opening in the same tab 1 , 2 .例如 Adobe Reader 似乎不支持在同一个选项卡中打开 1、2 As @KJ commented while I was typing my answer, sumatrapdf -reuse-instance seem to be suitable for you.正如@KJ 在我输入答案时评论的那样, sumatrapdf -reuse-instance似乎适合您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM