酷!學園
技術討論區 => 網頁技術 => 主題作者是: tonyvan123 於 2014-07-17 17:00
-
上網看了.測了不少程式都沒成功
測試用WIN XP+IE8 和 WIN 7 + IE11
-
function jsSubmit() {
errfound = false;
if(navigator.userAgent.indexOf("Chrome")>0) {
document.frmLogon.txtBrowser.value="isChrome";
} else if (navigator.userAgent.indexOf("MSIE 7") > 0) {
document.frmLogon.txtBrowser.value="isIE7";
IETrustExec1();
} else if (navigator.userAgent.indexOf("Gecko") > 0) {
document.frmLogon.txtBrowser.value="isIE11";
} else if (navigator.userAgent.indexOf("MSIE") > 0) {
document.frmLogon.txtBrowser.value="isIE";
IETrustExec1();
} else if (navigator.userAgent.indexOf("Firefox") > 0) {
document.frmLogon.txtBrowser.value="isFirefox";
} else if(navigator.userAgent.indexOf("isOpera")>0) {
document.frmLogon.txtBrowser.value="isOpera";
} else if(navigator.userAgent.indexOf("Safari")>0) {
document.frmLogon.txtBrowser.value="isSafari";
} else {
document.frmLogon.txtBrowser.value=navigator.appName + navigator.appVersion;
};
if (errfound == true) document.frmLogon.query.value="Error";
else document.frmLogon.query.value="submit";
};
-
function IETrustExec1() {
alert("enter IETrustExec1!");
//將抓到網址列的位址 加入信任網站
var objnav =navigator;
var OsVersion = objnav.appVersion;
var url =window.location.hostname; //抓網址列上的值
var urllength =url.length;
var domain1; //存放網址第一個.的前段
var domain2; //存放網址第一個.的後段
var num =url.indexOf("."); //找第一個"."
var rule= /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/; //驗證是否為ip格式的正規表示式
OsVersion= OsVersion.substring(38,41); //抓OS的版本
alert(url + OsVersion);
LoadActiveX();
var WshShell=new ActiveXObject("WScript.Shell");
alert("WshShell");
//判斷系統版本
if (OsVersion =="5.0") //win2000
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="5.1") //winXP
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="5.2") //Win2003
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscRanges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscRanges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscRanges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscDomains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscDomains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\EscDomains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="6.0") //vista
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="6.1") //Win 7 ,Win 2008
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="6.2") //Win 8 ,Win 2012
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
if (OsVersion =="6.3") //Win 8.1 ,Win 2012 R2
{
//判斷url為ip或domain
if(rule.test(url))
{
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\","");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\http","2","REG_DWORD");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Ranges\\Range100\\:Range",url);
} else {
domain1=url.substring(0,num);
domain2=url.substring((num+1),urllength);
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1,"");
WshShell.RegWrite("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\InternetSettings\\ZoneMap\\Domains\\"+domain2+"\\"+domain1+"\\http","2","REG_DWORD");
}
}
document.frmLogon.txtOPr.value="OsVersion";
//先取得IE的版本
var tIEVersion = getClientIEVersion();
//如果是IE7.0以上的話,把tab的設定改成1:在新視窗中啟動
if(tIEVersion>6)
{
WshShell.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\TabbedBrowsing\\PopupsUseNewWindow", 1, "REG_DWORD");
}
alert("exit IETrustExec1!");
};
-
function LoadActiveX() {
try {
var fso = new ActiveXObject("Scripting.FileSystemObject");
} catch(e) {
alert('未將本站加入信任網站!');
return;
}
}