做了个用来通知论坛有新贴子的hta
把下面的代码copy到本地另存为hta双击就可以执行了,出现新帖子会在右下角冒个窗口出来通知,10s后自动关闭通知窗口
复制代码 代码如下:
<html>
<head>
<title>BlueIdeaBoardWatcher-ByHutia</title>
<>
<hta:applicationid="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"/>
<>
<metahttp-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{
varxmlHttp=newActiveXObject("Microsoft.XMLHTTP");
varadodbStream=newActiveXObject("ADOD"+"B.St"+"ream");
}catch(e){
document.write("<h3>加载失败,组件被禁止</h3>");
}
thisDomain=location.href.substring(0,location.href.lastIndexOf("/"));
//将上次访问的结果保存在ree中用来与下次作对比
ree=newArray();
//用于判断是否初始化完毕的变量
inited=false;
//保存打开的窗口的数组
theWin=newArray();
//初始化函数
functioninit(){
startCheck();
}
//发送get请求
functionstartCheck(){
xmlHttp.open("get",url,true);
xmlHttp.send();
xmlHttp.onreadystatechange=checkState;
}
//确认xmlHttp返回的结果
functioncheckState(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
//解码获得返回值
varstrHTML=b2s(xmlHttp.responseBody);
variStart=strHTML.search(/<tablecellspacing=0cellpadding=0width="99%"border=0>/i);
variEnd=strHTML.indexOf("rn</table>rn",iStart);
strHTML=strHTML.substring(iStart,iEnd);
try{
f1.document.open();
f1.document.clear();
f1.document.write(strHTML);
f1.document.close();
}catch(e){}
//将返回值中的链接改成绝对地址
for(vari=0;i<f1.document.links.length;i++){
f1.document.links[i].href=f1.document.links[i].href.replace(thisDomain,"http://www.blueidea.com/bbs");
}
varresult=newArray();
try{
vartheTable=f1.document.all.tags("TABLE")[1];
for(vari=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(variinresult){
popupWin(i,result[i]);
}
}catch(e){}
}
setTimeout(startCheck,intervals);
return(false);
}
}
//弹出窗口
functionpopupWin(strURL,strText){
varmx=screen.availWidth;
varmy=screen.availHeight;
varw=200;
varh=150;
theRow=d1.insertRow(0);
theCell=theRow.insertCell();
theCell.innerHTML="<li><atarget="_blank"href=""+strURL+"">"+strText+"</a>";
strHTML="<html><head><title>"+strText+"</title>";
strHTML+="<style>body{margin:0px;padding:6px;background-Color:#D0FFD0;overflow:auto;}rn";
strHTML+="div{width:100%;height:100%;overflow:hidden;text-overflow:ellipsis;";
strHTML+="text-indent:12px;border:#9991pxsolid;cursor:hand;color:#005500;}</style>";
strHTML+="<bodyonload="setTimeout('window.close();',10000);">";
strHTML+="<divonclick="window.open('"+strURL+"');window.close();">";
strHTML+=strText;
strHTML+="</div></body></html>";
for(vari=0;i<theWin.length;i++){
if(theWin[i].closed){
varn=parseInt(my/120);
varl=parseInt(i/n)+1;
varstrModal="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);
}
}
varn=parseInt(my/120);
varl=parseInt(i/n)+1;
varstrModal="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);
}
functionb2s(b){
adodbStream.Type=1;//1=adTypeBinary
adodbStream.Open();
adodbStream.write(b);
adodbStream.position=0;
adodbStream.Type=2;
adodbStream.charset="gb2312";
//adodbStream.charset="_autodetect_all";
varre=adodbStream.readText();
adodbStream.close();
return(re);
}
window.attachEvent("onload",init);
</script>
</head>
<body>
<h3>Latest:</h3>
<tableid=d1></table>
<iframeid="f1"></iframe>
</body>
</html>