在活动浏览器选项卡中从 Windows 应用程序打开 URL
我正在尝试在活动浏览器选项卡中打开 URL(不应创建新窗口或选项卡)。我可以通过创建 IE 对象然后使用 IE.navigate2() 函数来使用 IE 来完成此操作,但我想知道是否可以以通用方式为所有浏览器完成此操作。如果没有,我该怎么办?
I am trying to open a URL in the active browser tab (no new window or tab should be created). I'm able to do this with IE by creating its object and then using the IE.navigate2()
function but I want to know whether it can be done in a generic way, for all browsers. If not, how should I go about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
说实话,我根本不会这么做。您假设您的应用正在执行的任务比用户已经在执行的任务更重要。例如,如果用户正在填写在线纳税申报表怎么办?如果您的应用程序随后在现有浏览器窗口中启动页面,它们将丢失所做的任何工作。
另外,如果用户一开始没有打开浏览器会发生什么?您必须在该实例中创建一个新窗口,那么为什么不在所有其他实例中创建一个新窗口呢?
在我看来,黄金法则是永远不要劫持用户已经在应用程序中执行的任何操作 - 总是有另一种方法可以做到这一点,不会让用户感到烦恼。
To be honest, I wouldn't do it at all. You're making an assumption that the task your app is performing is more important than what the user is already doing. What if the user is, for example, filling out an online tax return? If your app then launches a page in the existing browser window, they would lose any work they had done.
Also, what happens if the user doesn't have a browser open in the first place? You're going to have to create a new window in that instance, so why not in all other instances?
The golden rule, in my opinion, is NEVER to hijack anything to user is already doing in an application - there is always another way to do it that won't annoy the user anything like as much.