1.在脚本中设置背景颜色:document.bgcolor="red"
2.javascript脚本中窗口的定位和调整大小:
function win() {
if (window.screen) {
window.moveto(0, 0);
window.resizeto(800, 600);
}
}
3.vbs中exit for 马上退出循环,后面的内容将得不到执行。所以需要在此之前要注意完成善后的处理。
4.如果没有明确声明变量,则可能会不小心改变一个全局变量的值。
<%
y = 1
call setlocalvariable
response.write y
sub setlocalvariable()
y = 2
end sub
%>
由于变量没有显式声明,上述脚本命令将返回 2。过程调用将 y 设置为 2 时,脚本引擎认为该过程是要修改全局变量:
最理想的变量使用情况如下例所示:
<%dim y = 1
call setlocalvariable
response.write y
sub setlocalvariable()
dim y
y = 2
end sub %>
这段脚本命令最终输出y值为 1,这是因为显式定义了两个名为 y 的变量。
这种细微的差别一般可能无妨大碍,但是当系统大到一定程度以后是必须注意的,因为可能出现很多莫名其妙的问题!!
5.学会定义并且使用常量。
6.在这里,dateserial 函数返回 1998 年 11 月 10 日之前二十年 (1990-20) 零两个月 (11-2) 又一天 (10-1) 的日期:即 1978 年 9 月 9 日。程序如下: datep=dateserial(1998-20, 11-2,10-1)
7. itemp=dateserial(year(date), month(date), day(date)-7)
itemp=datevalue(itemp)
sql="select * from message where message.creatime
between #"&date&"#
and #"&itemp&"# "
在这里我们又接触到了一组函数 year,month,day,它们是用来得到一个日期的年、月、日。date 是常数,表示今天日期,而函数 datevalue 则是将字符串变量转化为日期格式的变量。在本段程序的第三行,我们第一次接触到了标准的 sql 查询语句,这句语句是什么意思呢?
“select”是标准的 sql 数据库查询命令,通过 select 语句我们可以在数据库中检索数据,并将查询结果提供给用户,此处的“*”表示查询该名为“message”的数据库中的所有记录,而“where”的作用是设定一个查询条件,是为了将数据库中符合条件的记录取出来,“message.creatime”是一个储存了数据库中记录创建日期的变量。将整句语句连起来理解就是:查询名为 message 的数据库中的所有记录,并将其中创建日期在今天和今天以前七日以内的所有记录存储在变量 sql 中。
9 .if {statement} elseif {statement} elseif {……} else {statement} end if(记得换行)
10.if {statement} else {statement} 对于比较短的语句可以有这种精简的格式
11.用ole方式连接sql server:
conn_ole.asp
<%
set conn = server.createobject("adodb.connection")
conn.open "provider=sqloledb;data source=10.1.43.238,2433; uid=course_user;pwd=course_password;database=course"
%>
12.我也记不清当初为什么记下这段程序,course_dsn应该就是指dsn吧。。
<%
set conn=server.createobject("adodb.connection") 创建连接数据库的对象
conn.open "course_dsn","course_user","course_password" 使用该对象连接数据库
conn.execute "delete from user_info"
%>
结果:user_info表中所有数据被删除
13.真正的无缓存实现:
response.buffer=true
response.cachecontrol="no-chache"
response.expiresabsolute=now()-1
response.expires=0
14.将服务器端的数据读到客户端的变量中的一种方法:
var onecount;
onecount=0;
subcat = new array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new array("<%= trim(rs("nsort_name"))%>","<%= trim(rs("sort_id"))%>","<%= trim(rs("nsort_id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
----待续
