How can i detected the browser type in my silverlight application?
for example i want to know if my silverlight application is running on IE or Firefox Or GoogleChrome... 开发者_如何学编程
i'm using silverlight 4 and my programming language is c#
Use the HtmlPage.BrowserInformation
property.
Code Example (given a TextBlock
called "txtOut"):-
txtOut.Text = String.Format("Name: {0}\nVersion: {1}\nProduct Name: {2}\nProduct Version: {3}\nUser Agent: {4}\nPlatform: {5}",
HtmlPage.BrowserInformation.Name,
HtmlPage.BrowserInformation.BrowserVersion,
HtmlPage.BrowserInformation.ProductName,
HtmlPage.BrowserInformation.ProductVersion,
HtmlPage.BrowserInformation.UserAgent,
HtmlPage.BrowserInformation.Platform);
I have IE 7 and Firefox 3.6.6 and it would seem that ProductName
and possible ProductVersion
would be you best choice to determine the browser.
If you are using JQuery, then u can use the Browser plugin of Jquery.
if you are using JS but not JQuery, then can follow this example from w3schools
If you are using JavaScript, then you can use navigator.appName for getting name of the browser.
精彩评论