首页 > 编程 > HTML > 正文

HTA编辑HOST文件的脚本

2024-08-26 00:15:48
字体:
来源:转载
供稿:网友
<HTML>
<HEAD>
<TITLE>HOSTS 文件编辑器</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta http-equiv="Content-Language" content="zh-CN">
<HTA:APPLICATION ID="hostedit"
APPLICATIONNAME="hostedit"
BORDER="thick"
BORDERSTYLE="normal"
CAPTION="yes"
ICON="C:/WINDOWS/system32/rasphone.exe" 
MAXIMIZEBUTTON="yes"
MINIMIZEBUTTON="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes"
VERSION="1.0"
WINDOWSTATE="normal" />
<script language="JScript">
window.onerror = function ()
{
    window.alert("程序发生了未知错误,当前窗口将被关闭!");
    window.close();
    return true;
}
var windowW=450;    //窗体宽
var windowH=200;    //窗体高
var canresize=false;//是否可以改变大小
var windowW2=windowW;//编辑时窗体宽
var windowH2=200;//编辑时窗体高
window.resizeTo(windowW,windowH);
//window.moveTo((screen.width-windowW)/2,(screen.height-windowH)/2);
window.onresize=function(){if(!canresize)window.resizeTo(windowW,windowH);}
function init()
{
    var ui_table = document.getElementById('UI_TABLE');
    var bestHeight = 70+ui_table.scrollHeight;
    if(bestHeight > screen.height) bestHeight = screen.height;
    window.resizeTo(windowW, bestHeight);
    //window.moveTo((screen.width-windowW)/2,(screen.height-bestHeight)/2);
}
var hostfile = '//drivers//etc//hosts';
function getlist(){
    var html='';
    var ids='';
    var i=1;
    FSO = new ActiveXObject("Scripting.FileSystemObject");
    var spath = FSO.GetSpecialFolder(1)+hostfile;
    host = FSO.OpenTextFile(spath, 1, false);
    while(!host.AtEndOfStream){
         tmp = host.ReadLine();
         if(/^#?/d{1,3}/./d{1,3}/./d{1,3}/./d{1,3}/s+([a-zA-Z0-9/-]+/.[a-zA-Z0-9/-]+(/.(com|net|org|edu|info|biz|cc|tv|gov|mobi|name|cn|en|us|hk|tw))+)$/.test(tmp))
         {
        as=tmp.replace(//s+/,'|:|').split('|:|');
        ids+='['+i+'],';
        if(/^/#/.test(as[0])){
            zt = '外网';
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表