1. 准备js。参考了一个js弹出层的例子。最后自动输出exe,类似flash安装。ie可以自动安装,其他浏览器需要手动下载安装包。

代码
1 var isOK = Silverlight.isInstalled("4.0.50524.0");
2  if (!isOK) {
3 var msgw, msgh, bordercolor;
4 msgw = 450; //提示窗口的宽度
5   msgh = 150; //提示窗口的高度
6   titleheight = 25 //提示窗口标题高度
7   bordercolor = "#336699"; //提示窗口的边框颜色
8 titlecolor = "#99CCFF"; //提示窗口的标题颜色
9
10 var sWidth, sHeight;
11 sWidth = document.body.offsetWidth; //浏览器工作区域内页面宽度
12 sHeight = screen.height; //屏幕高度(垂直分辨率)
13
14
15 //背景层(大小与窗口有效区域相同,即当弹出对话框时,背景显示为放射状透明灰色)
16 var bgObj = document.createElement("div"); //创建一个div对象(背景层)
17 //定义div属性,即相当于
18 //<div >

 

2. 在html里面调用该js,将silverlightfor window的安装文件和silverlightformac的安装文件放到根目录,命名为js中写的名字(Silverlight4forwindows.exe,Silverlight4formac.dmg)。

 

代码
<body>
<form id="form1" runat="server" style="height:100%">
<div id="silverlightControlHost">
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/AutoInstallSilverlight.xap"/>
<param name="onError" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50401.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
</a>
</object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
</form>
<script language="javascript" src="autoInstall.js"></script>
</body>

3. 预览效果,呵呵

自动安装silverlight,类似flash自动安装

4. 可以调整的地方。

删除 这一句,就可以去掉微软的安装提示。

代码
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50401.0" style="text-decoration:none">
<img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="获取 Microsoft Silverlight" style="border-style:none"/>
</a>

源码:https://files.cnblogs.com/xiaokang088/AutoInstallSilverlightWebSite.rar 

相关文章:

  • 2022-12-23
  • 2021-08-05
  • 2022-01-05
  • 2022-03-11
  • 2021-06-26
  • 2021-06-16
  • 2021-06-26
猜你喜欢
  • 2021-05-30
  • 2021-05-03
  • 2022-01-14
  • 2021-08-25
  • 2021-05-31
  • 2021-06-14
相关资源
相似解决方案