再发一变量传递的有趣例子,万千变化,异常有意思!在此结构上,你还可以再改!
a.asp:从数据库读出某数据,并传送给b.asp
<%
db="Database1.mdb"
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(db)
set conn=server.createobject("adodb.connection")
conn.open connstr
sql="select * from a where id=1"
Set rs=conn.execute(sql)
response.write("<script>window.location='b.asp?d="&rs("yes")&"'</script>")
%>
b.asp:
<%
hh=request.querystring("d")
response.write "<script type='text/javascript'>var d=('"&hh&"');</script>"
%>
<script language="javascript" type="text/javascript">
var a="我是js中定义的变量a";
</script>
<script language="vbcript" type="text/vbscript">
Dim b
b="我是vb中定义的变量b"
MsgBox d
msgbox a
</script>
<script language="javascript" type="text/javascript">
alert(b);
alert(d);
</script>
效果是:客户端脚本里警告的内容就是从服务器数据库里读出来的内容!并且vb,js均能正确显示!
a.asp:从数据库读出某数据,并传送给b.asp
<%
db="Database1.mdb"
connstr="provider=microsoft.jet.oledb.4.0;data source="&server.mappath(db)
set conn=server.createobject("adodb.connection")
conn.open connstr
sql="select * from a where id=1"
Set rs=conn.execute(sql)
response.write("<script>window.location='b.asp?d="&rs("yes")&"'</script>")
%>
b.asp:
<%
hh=request.querystring("d")
response.write "<script type='text/javascript'>var d=('"&hh&"');</script>"
%>
<script language="javascript" type="text/javascript">
var a="我是js中定义的变量a";
</script>
<script language="vbcript" type="text/vbscript">
Dim b
b="我是vb中定义的变量b"
MsgBox d
msgbox a
</script>
<script language="javascript" type="text/javascript">
alert(b);
alert(d);
</script>
效果是:客户端脚本里警告的内容就是从服务器数据库里读出来的内容!并且vb,js均能正确显示!
Q:1428196631,百度:开发地 即可找到我,有事请留言!