用JavaScript作为Asp服务器端脚本语言怎么样写?
一般来说 和 javascript 差不多的。。说也说不清楚,呵呵,给个例子你看看吧
<%@language="javascript" codepage=936%>
<script language="javascript" runat=server>
var sn=RequestQueryString("sn");
var uid=RequestQueryString("uid");
var tstr=new RegExp("<title>([\\s\\S]{0,100})</title>","gi");
var timestr=new RegExp("<span class=\"time\">([\\s\\S]{0,30})</span>","gi");
var BeCreated=false;
function gethtml(url)
{
var getxml=new ActiveXObject("MicrosoftXMLHTTP");
getxmlopen ("GET",url,false);
getxmlsend(null);
getstr='';
getstr=getxmlresponseText;
getstr=getstrreplace(/<meta http-equiv="Content-Type" content="text\/html; charset=UTF-8">/,"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=GB2312\">");
var tmp=pstrexec(getstr);
var rstr=RegExp$1;
rstr=rstrreplace(endflag,"");
if(rstr!="") BeCreated=true;
tmp=tstrexec(getstr);
var mytitle=RegExp$1;
tmp=timestrexec(getstr);
var mytime=RegExp$1;
var allxml="<xml version=\"10\" encoding=\"gb2312\">";
allxml+="<article>";
allxml+="<id>"+sn+"</id>";
allxml+="<title>"+mytitle+"</title>";
allxml+="<time>"+mytime+"</time>";
//allxml+="<temp>"+tmp+"</temp>";
allxml+="<content><![CDATA[ "+rstr+"]]></content>";
allxml+="</article>";
return allxml;
}
function createXML(content){
var fso=new ActiveXObject("ScriptingFileSystemObject");
var dir=ServermapPath("/blog_"+uid);
if(!fsoFolderExists(dir)) fsoCreateFolder(dir);
var x=fsoCreateTextFile(ServermapPath("/blog_"+uid+"/blog_"+sn+"xml"),true);
xwriteLine(content);
xclose();
x=null;
fso=null;
}
var outputxml=gethtml("http://blogsinacomcn/u/"+sn);
if(BeCreated){
createXML(outputxml);
}
</script>
<script type="text/javascript">
function nextframe(){
if(documentreadyState=="complete")
{
topcframeN++;
topbeginAppendXML(topcframeN);
}
}
documentonreadystatechange=nextframe;
</script>
0条评论