在默认浏览器中打开网页 [英] Open a webpage in the default browser

查看:27
本文介绍了在默认浏览器中打开网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望我的用户能够在点击按钮时在默认浏览器中打开我公司的网页.我该怎么做?

I want my users to be able to click a button to open my company's webpage in the default browser when clicked. How would I do this?

我使用的是 VB.net,因此所有 .net 示例都可以接受.

I'm using VB.net so all .net examples are acceptable.

推荐答案

正如其他人所指出的,Process.Start() 是这里的方法.但是,有一些怪癖.值得花时间阅读这篇博文:

As others have indicated, Process.Start() is the way to go here. However, there are a few quirks. It's worth your time to read this blog post:

http://faithlife.codes/blog/2008/01/using_processstart_to_link_to/

总而言之,某些浏览器会导致它无缘无故地抛出异常,该函数可能会在非 UI 线程上阻塞一段时间,因此您需要确保它在您可能执行的任何其他操作结束时发生同时,您可能希望在等待浏览器打开时更改光标外观.

In summary, some browsers cause it to throw an exception for no good reason, the function can block for a while on non-UI thread so you need to make sure it happens near the end of whatever other actions you might perform at the same time, and you might want to change the cursor appearance while waiting for the browser to open.

这篇关于在默认浏览器中打开网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆