


小阁常用网页语句

设置函数articles,可以在中间读取、更新记录以及设置各类执行函数。
设置函数xx来获取表articles中id小于10的个数,括号内ID为变量。
设置函数yy来执行语句,让字段x的值加1,括号内ID为变量。
设置函数zz对各个字段进行声明来更新记录,括号内ID为变量。
---------------------------------------------------------------------------------------
连接上一级目录里appCode中的Conn.asp代码。
<!--#include file="../appCode/Conn.asp"-->
定义域名参数id。
id=Request.QueryString("id")
当全局参数style为1时。
If Application(SiteID & "style")="1" then
定义Sql语句来执行数据库的表articles。
Sql = "select * from articles where ID=" & ID
定义rs来执行这条Sql语句。
Set rs = Conn.Execute(Sql)
通过链接参数读取数据。
<!--#include file="AppCode/Conn.asp"-->
<%
dim id
Id = Request.QueryString("Id")
Sql="select * from articles where id="&id&" order by ID"
Rs.Open Sql,Conn,1,1
If Not(Rs.Eof And Rs.Bof) Then
%>
<%=rs("title")%>
<%End If%>
通过链接参数读取多条数据。
<!--#include file="AppCode/Conn.asp"-->
<%
dim id
Id = Request.QueryString("Id")
Sql="select top 6 * from articles where id>"&id&" order by ID"
Set Rs=Conn.Execute(Sql)
Do While Not Rs.Eof
%>
<%=Rs("title")%><br>
<%Rs.MoveNext
Loop
Rs.Close
%>
通过链接参数更新数值。
<!--#include file="AppCode/Conn.asp"-->
<%
dim title
title=Request.QueryString("title")
sql = "update articles set title="&title&" where id="&id /*如果是删除则改为delete from articles where id="&id即可*/
Conn.Execute sql
%>
获取最大的ID。
<!--#include file="AppCode/Conn.asp"-->
<%
Public Function GetMaxArticleID()
Set clsRs = Server.CreateObject("Adodb.RecordSet")
Sql = "select max(ID) from articles"
clsRs.Open Sql,Conn,0,1
If IsNull(clsRs(0)) Then
GetMaxArticleID = 0
Else
GetMaxArticleID = clsRs(0)
End If
clsRs.Close
Set clsRs = Nothing
End Function
%>
<%=GetMaxArticleID()%>
让某个参数值加1。
<!--#include file="AppCode/Conn.asp"-->
<%
Public Sub HitsAdd(ID)
Sql = "update articles set Hits = Hits + 1 where Id=" & ID
Conn.Execute Sql
End Sub
%>
<%call HitsAdd(1)%>
判断分类30里有没有子分类。
<!--#include file="AppCode/Conn.asp"-->
<%
Public Function IsHaveNextClass(ClassId)
Sql = "select count(ID) from class where ParentID=" & ClassId
If Conn.Execute(Sql)(0)=0 Then
IsHaveNextClass = False
Response.Write("0")
Else
IsHaveNextClass = True
Response.Write("1")
End If
End Function
%>
<%call IsHaveNextClass(30)%>
当Sql语句中字段x的值不为0时。
If Conn.Execute("select x from articles where ID=" & ID)(0)<>0 then
或
If Conn.Execute(Sql)(0)<>0 then
设置函数articles,可以在中间读取、更新记录以及设置各类执行函数。
Class articles
End Class
设置函数xx来获取表articles中id小于10的个数,括号内ID为变量。
Public Function xx(ID)
Sql = "select count(*) from articles where id < "& ID
Conn.Execute Sql
End Sub
或
function xx(ID)
xx=conn.execute("select count(*) from articles where id < "&ID)(0)
end function
设置函数yy来执行语句,让字段x的值加1,括号内ID为变量。
Public Sub yy(ID)
Sql = "update articles set x = x + 1 where Id=" & ID
Conn.Execute Sql
End Sub
设置函数zz对各个字段进行声明来更新记录,括号内ID为变量。
Private Sub zz(ID)
Sql="select * from articles where ID=" & ID
Set oRs=Conn.Execute(Sql)
Rs("Title") = SortName
Rs("ID2") = ID2
End Sub
当某个表的某个字段在某个ID上的值为1时。
If Conn.Execute("select tuliebiao from class where ID=" & ClassID)(0)=1"" then
当符合某个条件时,为Sql语句增加一个条件。
Sql = "select * from articles where IsDelete=" & IsDelete
If ID>"10" Then
Sql = Sql & " and ID2 = " & ID2
End If
更新字段ID。
Rs("ID") = ID
从记录集中读取字段ID。
ID = Rs("ID")
设置名称Article来指代函数articles。
Set Article = New articles
获取函数article中AddTime字段的值。
<%=Article.AddTime%>
引用函数Article中的Add执行函数。
Call Article.Add()
跳转到页面index.asp。
Response.Redirect("index.asp")
当手机浏览时。
If regex.test(agent) then
当不是手机浏览时。
If not regex.test(agent) then
当浏览器为极速浏览器时。
If Instr(BrowserString,broMSIE)=0 then
当浏览器为兼容浏览器时。
If Instr(BrowserString,broMSIE)<>0 then
当浏览器为极速模式时自动跳转到另一个编辑器。
<%If editor<>"" then%>
<%Else%>
<script language="javascript">
if(window.navigator.userAgent.indexOf("AppleWebKit") != -1) {
window.location.href="?Id=<%=id%>&editor=2";
}
</script>
<%End If%>
当管理员操作时。
If InStr(admin.GroupId,",3,")>=1 then
如果当前IP地址被屏蔽时或当前IP为站长IP时。
If IsForbidIP(nocountIPGroup) = True then
16张图片每四张换一行进行排列。
<%For i=1 To 16%>
<img src="<%=i%>.gif">
<%If i Mod 4 =0 Then%>
<br>
<%End If%>
<%Next%>
当当前浏览器为IE时。
if Instr(BrowserString, broMSIE) <> 0 then
为Firefox时。
if Instr(BrowserString, broFirefox) <> 0 then
为Opera时。
if Instr(BrowserString,broOpera)<>0 then
为Wap时。
if Instr(BrowserString, broWap) <> 0 then
点击按钮跳转到首页。
<input type="button" name="Submit" value="跳转到首页" onClick="javascript:window.location.href='../index.asp'">
当字段的字节数超过30时。
If len(Title) >= 30 then
把字段内容或参数“aa”里的“6”全改为“8”。
<%=replace("aa","6","8")%>
按钮控制div移动。
<style type="text/css">
#content {
position: absolute;
left: 100px;
top: 100px;
width: 155px;
height: 100px;
background: palevioletred;
}
</style>
<div id="content">
<input type="button" value="上" id="top">
<input type="button" value="下" id="bottom">
<input type="button" value="左" id="left">
<input type="button" value="右" id="right">
</div>
<script>
var top = document.getElementById("top");
var bottom = document.getElementById("bottom");
var left = document.getElementById("left");
var right = document.getElementById("right");
var content = document.getElementById("content");
var index = 100;
top.onclick = function () {
index = index - 10;
content.style.top = index + "px";
}
bottom.onclick = function () {
index = index+ 10;
content.style.top = index + "px";
}
left.onclick = function () {
index = index - 10;
content.style.left = index + "px";
}
right.onclick = function () {
index = index + 10;
content.style.left = index + "px";
}
</script>
让气泡在方盒子里飘动。
<style type="text/css">div{position:absolute;}</style>
<div id="floatdiv"><img src="http://youxiange.cn/main/image/qipao80.png" height="150px" width="150px"></div>
<script language="javascript" type="text/javascript">
var img=document.getElementById("floatdiv");
var x=0,y=0;
var xSpeed=0.2,ySpeed=0.2;
h=document.documentElement.clientHeight;
var w=document.body.clientWidth-200,
h=document.body.clientHeight-100;
function floatdiv(){
if(x>w||x<0) xSpeed= -xSpeed;
if(y>h||y<0) ySpeed= -ySpeed;
x+=xSpeed;
y+=ySpeed;
img.style.top=y+"px";
img.style.left=x+"px";
setTimeout("floatdiv()",10);
}
floatdiv();
</script>
JS实现上下浮动的窗口效果。
<style type="text/css">
<!--
a:hover{color:00ff00}
a {color:000000;text-decoration:none}
-->
</style>
<div id="floatpoint" STYLE="position:absolute;visibility:visible;">
<table border=1 cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolor="#FFFFFF">
<tr>
<td align=center bgcolor=#E3E3E3 style="color:HIGHLIGHTTEXT">
<font color="#000000">
最新消息!</font>
</td>
</tr>
</table>
</div>
<script LANGUAGE="JavaScript1.2">
//这部分为用户自定义区
var XX=10; // 浮动层的X坐标,即左边距
var xstep=1; // 移动步长,此参数越小,移动越平滑,最小值为1
var delay_time=40; // 每步的时间间隔,此参数越小,移动速度越快
//以下部分请勿随意改动
var YY=0;
var ch=0;
var oh=0;
var yon=0;
var ns4=document.layers?1:0
var ie=document.all?1:0
var ns6=document.getElementById&&!document.all?1:0
if(ie){ //如果是IE
YY=document.body.clientHeight;
floatpoint.style.top=YY;
}
else if (ns4){
YY=window.innerHeight;
document.floatpoint.pageY=YY;
document.floatpoint.visibility="hidden";
}
else if (ns6){
YY=window.innerHeight
document.getElementById('floatpoint').style.top=YY
}
function reloc1(){
if(yon==0){YY=YY-xstep;}
else{YY=YY+xstep;}
if (ie){
ch=document.body.clientHeight;
oh=floatpoint.offsetHeight;
}
else if (ns4){
ch=window.innerHeight;
oh=document.floatpoint.clip.height;
}
else if (ns6){
ch=window.innerHeight
oh=document.getElementById("floatpoint").offsetHeight
}
if(YY<0){yon=1;YY=0;}
if(YY>=(ch-oh)){yon=0;YY=(ch-oh);}
if(ie){
floatpoint.style.left=XX;
floatpoint.style.top=YY+document.body.scrollTop;
}
else if (ns4){
document.floatpoint.pageX=XX;
document.floatpoint.pageY=YY+window.pageYOffset;
}
else if (ns6){
document.getElementById("floatpoint").style.left=XX
document.getElementById("floatpoint").style.top=
YY+window.pageYOffset
}
}
function onad(){
if(ns4)
document.floatpoint.visibility="visible";
loopfunc();
}
function loopfunc(){
reloc1();
setTimeout('loopfunc()',delay_time);
}
if (ie||ns4||ns6)
window.onload=onad
</script>
JS显示隐藏内容。
<P class="hand-cursor" onclick='hideOrShow("xx")' title=有内容>显示/隐藏</P>
<div id="xx" class=display>内容</div>
<script type="text/javascript">
function hideOrShow(id){
var node=document.getElementById(id);
if(node.style.display=="block"){
node.style.display="none";
}else{
node.style.display="block";
}
}
</script>