首页 > 编程 > HTML > 正文

用来通知论坛有新贴子的hta代码

2020-01-25 19:40:46
字体:
来源:转载
供稿:网友
做了个用来通知论坛有新贴子的hta 

把下面的代码copy到本地另存为hta双击就可以执行了,出现新帖子会在右下角冒个窗口出来通知,10s后自动关闭通知窗口 
复制代码代码如下:

<html> 
<head> 
<title>Blue Idea Board Watcher - By Hutia</title> 
<!-- 程序设置,如果希望程序在任务栏显示,请将showintaskbar改为yes --> 
<hta:application id="app1" singleinstance="yes" contextmenu="yes" 
 sysmenu="yes" windowstate="normal" maximizeButton="no" minimizeButton="yes" 
 applicationName="BlueIdeaBoardWatcher" version="1.0" innerBorder="no" 
 caption="yes" showintaskbar="no" border="thin" /> 
<!-- 语种 gb2312 --> 
<meta http-equiv="content-type" content="text/html; charset="gb2312">  
<!-- 样式表 --> 
<style> 
body, td { 
    margin:0px; 
    padding:5px; 
    overflow:auto; 
    font-size:12px; 


h3 { 
    font-size:14px; 


iframe { 
    display:none; 

</style> 
<script> 
//******全局变量区***** 
// 经典论坛 > Dreamweaver & Javascript专栏 
url="http://bbs.blueidea.com/forumdisplay.php?fid=1"; 

// 刷新间隔 10s 
intervals=10000; 

//初始化组件 
try{ 
    var xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    var adodbStream=new ActiveXObject("ADOD"+"B.St"+"ream"); 
}catch(e){ 
    document.write("<h3>加载失败,组件被禁止</h3>"); 


thisDomain=location.href.substring(0,location.href.lastIndexOf("//")); 
//将上次访问的结果保存在ree中用来与下次作对比 
ree=new Array(); 
//用于判断是否初始化完毕的变量 
inited=false; 
//保存打开的窗口的数组 
theWin=new Array(); 

//初始化函数 
function init(){ 
    startCheck(); 


//发送get请求 
function startCheck(){ 
    xmlHttp.open("get",url,true); 
    xmlHttp.send(); 
    xmlHttp.onreadystatechange=checkState; 


//确认xmlHttp返回的结果 
function checkState(){ 
    if (xmlHttp.readyState==4){ 
        if (xmlHttp.status==200){ 
            //解码获得返回值 
            var strHTML=b2s(xmlHttp.responseBody); 
            var iStart=strHTML.search(/<table cellspacing=0 cellpadding=0 width="99%" border=0>/i); 
            var iEnd=strHTML.indexOf("/r/n<//table>/r/n",iStart); 
            strHTML=strHTML.substring(iStart,iEnd); 
            try{ 
                f1.document.open(); 
                f1.document.clear(); 
                f1.document.write(strHTML); 
                f1.document.close(); 
            }catch(e){} 
            //将返回值中的链接改成绝对地址 
            for(var i=0;i<f1.document.links.length;i++){ 
                f1.document.links[i].href=f1.document.links[i].href.replace(thisDomain,"http://www.blueidea.com/bbs"); 
            } 
            var result=new Array(); 
            try{ 
                var theTable=f1.document.all.tags("TABLE")[1]; 
                for(var i=1;i<theTable.rows.length;i++){ 
                    strU=theTable.rows[i].cells[3].firstChild.href; 
                    strT=theTable.rows[i].cells[3].firstChild.innerHTML; 
                    strC=theTable.rows[i].cells[6].innerText; 
                    if(inited){ 
                        if(ree[strU]!=strC){ 
                            ree[strU]=strC; 
                            result[strU]=strT; 
                        } 
                    }else{ 
                        ree[strU]=strC; 
                    } 
                } 
                inited=true; 
                for(var i in result){ 
                    popupWin(i,result[i]); 
                } 
            }catch(e){} 
        } 
        setTimeout(startCheck,intervals); 
        return(false); 
    } 


//弹出窗口 
function popupWin(strURL,strText){ 
    var mx=screen.availWidth; 
    var my=screen.availHeight; 
    var w=200; 
    var h=150; 

    theRow=d1.insertRow(0); 
    theCell=theRow.insertCell(); 
    theCell.innerHTML="<li><a target=/"_blank/" href=/""+strURL+"/">"+strText+"</a>"; 

    strHTML="<html><head><title>"+strText+"</title>"; 
    strHTML+="<style>body{margin:0px;padding:6px;background-Color:#D0FFD0;overflow:auto;}/r/n"; 
    strHTML+="div{width:100%;height:100%;overflow:hidden;text-overflow:ellipsis;"; 
    strHTML+="text-indent:12px;border:#999 1px solid;cursor:hand;color:#005500;}</style>"; 
    strHTML+="<body onload=/"setTimeout('window.close();',10000);/">"; 
    strHTML+="<div onclick=/"window.open('"+strURL+"');window.close();/">"; 
    strHTML+=strText; 
    strHTML+="</div></body></html>"; 
    for(var i=0;i<theWin.length;i++){ 
        if(theWin[i].closed){ 
            var n=parseInt(my/120); 
            var l=parseInt(i/n)+1; 
            var strModal="dialogWidth="+w+"px;dialogHeight="+h+"px;dialogLeft="+(mx-w*l)+"px;dialogTop="+(my-h*(i%n+1)); 
            theWin[i]=showModelessDialog("about:blank",strText,strModal); 
            theWin[i].document.open(); 
            theWin[i].document.clear(); 
            theWin[i].document.write(strHTML); 
            theWin[i].document.close(); 
            theWin[i].focus(); 
            return(false); 
        } 
    } 
    var n=parseInt(my/120); 
    var l=parseInt(i/n)+1; 
    var strModal="dialogWidth="+w+"px;dialogHeight="+h+"px;dialogLeft="+(mx-w*l)+"px;dialogTop="+(my-h*(i%n+1)); 
    theWin[i]=showModelessDialog("about:blank",strText,strModal); 
    theWin[i].document.open(); 
    theWin[i].document.clear(); 
    theWin[i].document.write(strHTML); 
    theWin[i].document.close(); 
    theWin[i].focus(); 
    return(false); 


function b2s(b){ 
    adodbStream.Type=1;//1=adTypeBinary 
    adodbStream.Open(); 
    adodbStream.write(b); 
    adodbStream.position=0; 
    adodbStream.Type=2; 
    adodbStream.charset="gb2312"; 
    //adodbStream.charset="_autodetect_all"; 
    var re=adodbStream.readText(); 
    adodbStream.close(); 
    return(re); 


window.attachEvent("onload",init); 

</script> 
</head> 

<body> 
<h3>Latest:</h3> 
<table id=d1></table> 
<iframe id="f1"></iframe> 
</body> 
</html>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表