如何将ASP程序转换成JS格式在HTML调用

JavaScript029

如何将ASP程序转换成JS格式在HTML调用,第1张

转换容易,但是你要明白,你的HTML页面是不支持ASP的,所以你即使调用了写成js格式的ASP代码,但是实际上还是需要执行ASP代码,所以,你只有把HTML页面改成ASP格式后,才能用script src="xxx.asp"></script>调用xxx.asp页面,xxx.asp页面这里我给你转换了,如下

<script language="JavaScript">

<!--

document.writeln("<%")

document.writeln("dim user")

document.writeln("user=request("user")")

document.writeln("dim rs,sql")

document.writeln("set rs=server.createobject("adodb.recordset")")

document.writeln("sql="select TOP 1 jf from AosQzone_Cn_Link where user='"&user&"'"")

document.writeln("rs.open sql,conn,1,2")

document.writeln("If not rs.eof then")

document.writeln("rs("jf")=rs("jf")+1")

document.writeln("rs.update")

document.writeln("end if")

document.writeln("")

document.writeln("rs.close")

document.writeln("set rs=nothing")

document.writeln("%>")

//-->

</script>

怎么不能转换???

LZ出发点很好...只是方法错了...

要用你的服务器端程序来生成静态页面,而不要生成js.

客户端可能不支持js的,而且这样做的话,SEO角度上讲完全是大错特错...

所以你要做的就是用你的服务端程序把你的新闻读出来,然后生成静态页面,然后以后访问的时候就是直接访问这个静态页面了...

比较麻烦,如果不是全才,真的可以不用去研究技术.做别的吧...这些交给技术员,或者是用现成的网站系统程序去做.

这样试试:

<!--#include file="conn.asp"-->

<%if request("action")<>"save" then%>

<%

Response.ContentType="application/x-javascript"

id=request.querystring("ID")

if not IsNumeric(id) then

t=request.querystring()

ips=Request.ServerVariables("Remote_Addr")

sj=now

conn.Execute "INSERT INTO log(username,action,ip,sj) VALUES('sql注入[pl.asp]','收到“"&t&"”','"&ips&"','"&sj&"' )"

conn.close

response.write "window.location='/'"

response.End()

end if

set rs=server.createobject("adodb.recordset")

sql="select id,title from article where id="&id&""

rs.open sql,conn,1,1

if rs.eof or rs.bof then

response.Write("document.write('文章不存在')")

response.end

else

title=rs("title")

articleid=rs("id")

rs.close

end if

%>

然后使用 <script language="javascript" src="xxx.asp"></script>。注意是“src”,不是“scr”!“xxx.asp”就是上面的程序存成“.asp”文件之后的文件(路径)。

欢迎光临:http://hi.baidu.com/littlechicken