参考 [完美]原生JS获取浏览器版本判断--支持Edge,IE,Chrome,Firefox,Opera,Safari,以及各种使用Chrome和IE混合内核的浏览器
利用js来判断
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//webBrowser1.Navigate(@"C:\Users\admin\Desktop\test.html");
webBrowser1.DocumentText = "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n\r\n <script type=\"text/javascript\">\r\n function getBroswer() {\r\n var sys = {};\r\n var ua = navigator.userAgent.toLowerCase();\r\n var s;\r\n (s = ua.match(/edge\\/([\\d.]+)/)) ? sys.edge = s[1] :\r\n (s = ua.match(/rv:([\\d.]+)\\) like gecko/)) ? sys.ie = s[1] :\r\n (s = ua.match(/msie ([\\d.]+)/)) ? sys.ie = s[1] :\r\n (s = ua.match(/firefox\\/([\\d.]+)/)) ? sys.firefox = s[1] :\r\n (s = ua.match(/chrome\\/([\\d.]+)/)) ? sys.chrome = s[1] :\r\n (s = ua.match(/opera.([\\d.]+)/)) ? sys.opera = s[1] :\r\n (s = ua.match(/version\\/([\\d.]+).*safari/)) ? sys.safari = s[1] : 0;\r\n\r\n if (sys.edge) return { broswer: \"Edge\", version: sys.edge };\r\n if (sys.ie) return { broswer: \"IE\", version: sys.ie };\r\n if (sys.firefox) return { broswer: \"Firefox\", version: sys.firefox };\r\n if (sys.chrome) return { broswer: \"Chrome\", version: sys.chrome };\r\n if (sys.opera) return { broswer: \"Opera\", version: sys.opera };\r\n if (sys.safari) return { broswer: \"Safari\", version: sys.safari };\r\n\r\n return { broswer: \"\", version: \"0\" };\r\n }\r\n function myFunction() {\r\n var d = getBroswer();\r\n alert(d.broswer + d.version);\r\n\r\n }\r\n myFunction();\r\n </script>\r\n</head>\r\n\r\n<body>\r\n <script type=\"text/javascript\">\r\n document.write(\"<p>UserAgent: \")\r\n document.write(navigator.userAgent + \"</p>\")\r\n </script>\r\n <h1 id=\"h01\"></h1>\r\n</body>\r\n</html>";
}
}
}