Silverlight HtmlPage使用之二 获得浏览器版本和系统版本信息

本文介绍了一段Silverlight应用程序代码,通过该程序可以获取当前浏览器的信息,包括浏览器版本、是否启用Cookies、浏览器名称、操作系统名称等。此示例展示了如何在Silverlight环境中与浏览器进行交互。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

xaml代码

<UserControlx:Class="SilverlightApplication1.HtmlPageControl"
xmlns=
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x=
"http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d=
"http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc=
"http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable=
"d"
d:DesignHeight=
"300"d:DesignWidth="400">

<Gridx:Name="LayoutRoot"Background="White">
<ButtonContent="Browser"Height="23"HorizontalAlignment="Left"
Margin=
"128,12,0,0"Name="button2"VerticalAlignment="Top"
Width="75"Click="button2_Click"/>

</Grid>
</UserControl>

  cs代码

privatevoidbutton2_Click(objectsender,RoutedEventArgse)
{
System.Windows.Browser.BrowserInformationbrowser=HtmlPage.BrowserInformation;
Versionver=browser.BrowserVersion;
intbuld=ver.Build;//浏览器版本内部编号
intminor=ver.Minor;//浏览器版本次要编号
intmajor=ver.Major;//浏览器版本主要编号
boolenableCookie=browser.CookiesEnabled;//浏览器是否支持Cookie
stringbrowserName=browser.Name;//浏览器名称
stringplatform=browser.Platform;//操作系统名称
stringproductName=browser.ProductName;//浏览器产品名称
stringproductVersion=browser.ProductVersion;//浏览器产品版号
stringuserAgent=browser.UserAgent;//用户代理字符串
//浏览显示请自写也可以用vs断点查看谢谢
}

本文来自mldark的博客,原文地址:http://hi.baidu.com/mldark/blog/item/3c6c0c0bd642b728b0351dfb.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值