Activate existing browser window with given URL from C# application (without triggering reload)

前端 未结 1 1742
温柔的废话
温柔的废话 2020-12-06 15:23

From a C# application I want to activate (brint to front) a site that is already open in the users default browser. I want to do this in a browser agnostic way.

The

相关标签:
1条回答
  • 2020-12-06 16:23

    This will work, IF the user has that site active in their browser. If they're using a tabbed browser, and the site is open, but not in the selected tab, I don't believe you will ever find the browser window. (EnumWindows only enumerates top-level windows).

    If the user's started a new tab, you'll end up not finding it, and (likely) starting a second copy of the site in a new tab.

    Personally, if you really need to restrict to a single browser instance, I would consider whether its possible to embed the browser in your application instead of using the default browser. If this can be made a GUI element in your application using a browser control, you'd have much more control and be able to avoid this type of workaround.

    0 讨论(0)
提交回复
热议问题