ActiveX下载(JavaScript实现,含setup.bat文件,创建自解压文件,ActiveX控件存在判断与自定义下载页面)
//ActiveX控件信息
<OBJECT id="FileClient" classid="clsid:9627E9EB-3636-42AF-80C2-3CE2E5541930" codeBase="FileClient.ocx#Version=1.2.0.9"></OBJECT>
//创建自解压文件
1。选中FileClient.ocx和setup.bat文件
2。右键单击选择'添加到压缩文件'
3。勾选'创建自解压格式压缩文件',文件后缀名自动变成.exe
4。选择'高级'标签,单击'自解压选项'
5。在自解压选项中,填写安装程序'解压后运行'->填入'setup.bat'
6。选择自解压选项的'模式'标签,勾选'解包到临时文件夹'项
7。确定即可
================================
//// test.html ////
<body id="main_content" onload="initActiveX();">
<DIV ID="ttt" STYLE='display:none;'></div>
</body>
</html>
<script type="text/javascript">
<!--
//ActiveX下载
function initActiveX(){
var pos=0;
var path="";
var codebasepath="ActiveX/FileClient.ocx#Version=1.2.0.9";
var dlurl = "ActiveX/msg.html";
try{
ttt.innerHTML = ("<OBJECT classid=clsid:9627E9EB-3636-42AF-80C2-3CE2E5541930 id=FileClient style=\"HEIGHT:100%; WIDTH:100%\" />");
aFileClient = document.getElementById("FileClient");
aFileClient.GetOcxVersion();
}catch(e){
alert("您尚未安装需要的ActiveX控件,请下载并安装该ActiveX控件!");
window.location.href = dlurl;
}
}
//-->
</script>
<OBJECT id="FileClient" classid="clsid:9627E9EB-3636-42AF-80C2-3CE2E5541930" codeBase="FileClient.ocx#Version=1.2.0.9"></OBJECT>
//创建自解压文件
1。选中FileClient.ocx和setup.bat文件
2。右键单击选择'添加到压缩文件'
3。勾选'创建自解压格式压缩文件',文件后缀名自动变成.exe
4。选择'高级'标签,单击'自解压选项'
5。在自解压选项中,填写安装程序'解压后运行'->填入'setup.bat'
6。选择自解压选项的'模式'标签,勾选'解包到临时文件夹'项
7。确定即可
================================
//// test.html ////
<body id="main_content" onload="initActiveX();">
<DIV ID="ttt" STYLE='display:none;'></div>
</body>
</html>
<script type="text/javascript">
<!--
//ActiveX下载
function initActiveX(){
var pos=0;
var path="";
var codebasepath="ActiveX/FileClient.ocx#Version=1.2.0.9";
var dlurl = "ActiveX/msg.html";
try{
ttt.innerHTML = ("<OBJECT classid=clsid:9627E9EB-3636-42AF-80C2-3CE2E5541930 id=FileClient style=\"HEIGHT:100%; WIDTH:100%\" />");
aFileClient = document.getElementById("FileClient");
aFileClient.GetOcxVersion();
}catch(e){
alert("您尚未安装需要的ActiveX控件,请下载并安装该ActiveX控件!");
window.location.href = dlurl;
}
}
//-->
</script>
//// ActiveX/msg.html ////
<HTML>
<head>
<meta http-equiv="Content-Type" content="text/HTML; charset=GB2312">
<title>下载ActiveX控件</title>
</head>
<link type="text/css" rel="stylesheet" href="../css/globe-base.css">
<body id="main_content">
<table class="common_table">
<tr>
<td class="head">
<span id="nav"> 请在此下载ActiveX控件 </span>
</td>
</tr>
<tr>
<td class="main" style="padding:6 0 6 12" height=50 valign="top">
<table width=100% border=0>
<tr>
<td class="p9line21">
您的浏览器未能自动安装组件,可能是因为您点击了否,或者您的浏览器安全设置。您还可以下载我们提供的安装包,然后在本地执行安装。 <BR>
<a href="FileClientSetup.exe"><b><font color=red>点击这里下载ActiveX控件</font></b></a>
下载完毕后执行即可。
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
<head>
<meta http-equiv="Content-Type" content="text/HTML; charset=GB2312">
<title>下载ActiveX控件</title>
</head>
<link type="text/css" rel="stylesheet" href="../css/globe-base.css">
<body id="main_content">
<table class="common_table">
<tr>
<td class="head">
<span id="nav"> 请在此下载ActiveX控件 </span>
</td>
</tr>
<tr>
<td class="main" style="padding:6 0 6 12" height=50 valign="top">
<table width=100% border=0>
<tr>
<td class="p9line21">
您的浏览器未能自动安装组件,可能是因为您点击了否,或者您的浏览器安全设置。您还可以下载我们提供的安装包,然后在本地执行安装。 <BR>
<a href="FileClientSetup.exe"><b><font color=red>点击这里下载ActiveX控件</font></b></a>
下载完毕后执行即可。
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</HTML>
//// setup.bat ////
Regsvr32 /u /s %windir%\system32\FileClient.ocx
Del %windir%\system32\FileClient.ocx
Copy FileClient.ocx %windir%\system32\FileClient.ocx
Regsvr32 /s %windir%\system32\FileClient.ocx
Del FileClient.ocx
Del FileClient.inf
Echo off
Cls
Echo *********************************************************
Echo *********************************************************
Echo *** ***
Echo *** ***
Echo *** Setup is succeeded! Press any key to close it! ***
Echo *** ***
Echo *** ***
Echo *********************************************************
Echo *********************************************************
Pause
Echo *********************************************************
Del setup.bat
Del %windir%\system32\FileClient.ocx
Copy FileClient.ocx %windir%\system32\FileClient.ocx
Regsvr32 /s %windir%\system32\FileClient.ocx
Del FileClient.ocx
Del FileClient.inf
Echo off
Cls
Echo *********************************************************
Echo *********************************************************
Echo *** ***
Echo *** ***
Echo *** Setup is succeeded! Press any key to close it! ***
Echo *** ***
Echo *** ***
Echo *********************************************************
Echo *********************************************************
Pause
Echo *********************************************************
Del setup.bat