1. asp與access數(shù)據(jù)庫連接:
dim conn,mdbfile
mdbfile=server.mappath("數(shù)據(jù)庫名稱.mdb")
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};uid=admin;pwd=數(shù)據(jù)庫密碼;dbq="&mdbfile
conn.open "provider = microsoft.jet.oledb.4.0;data source = " & mdbfile
2. asp與sql數(shù)據(jù)庫連接: dim conn
set conn=server.createobject("adodb.connection")
con.open "provider=sqloledb;data source=sql服務(wù)器名稱或ip地址;uid=sa;pwd=數(shù)據(jù)庫密碼;database=數(shù)據(jù)庫名稱;"
建立記錄集對象: set rs=server.createobject("adodb.recordset")
rs.open sql語句,conn,3,2
sql常用命令使用方法:
數(shù)據(jù)記錄篩選: sql="select * from 數(shù)據(jù)表 where 字段名=字段值 order by 字段名 "
sql="select * from 數(shù)據(jù)表 where 字段名 like ‘%字段值%‘ order by 字段名 "
sql="select top 10 * from 數(shù)據(jù)表 where 字段名 order by 字段名 "
sql="select * from 數(shù)據(jù)表 where 字段名 in (‘值1‘,‘值2‘,‘值3‘)"
sql="select * from 數(shù)據(jù)表 where 字段名 between 值1 and 值2" 更新數(shù)據(jù)記錄: sql="update 數(shù)據(jù)表 set 字段名=字段值 where 條件表達(dá)式"
sql="update 數(shù)據(jù)表 set 字段1=值1,字段2=值2 …… 字段n=值n where 條件表達(dá)式"
刪除數(shù)據(jù)記錄: sql="delete from 數(shù)據(jù)表 where 條件表達(dá)式"
sql="delete from 數(shù)據(jù)表" (將數(shù)據(jù)表所有記錄刪除)
添加數(shù)據(jù)記錄: sql="insert into 數(shù)據(jù)表 (字段1,字段2,字段3 …) valuess (值1,值2,值3 …)"
sql="insert into 目標(biāo)數(shù)據(jù)表 select * from 源數(shù)據(jù)表" (把源數(shù)據(jù)表的記錄添加到目標(biāo)數(shù)據(jù)表) 數(shù)據(jù)記錄統(tǒng)計函數(shù):
avg(字段名) 得出一個表格欄平均值
count(*|字段名) 對數(shù)據(jù)行數(shù)的統(tǒng)計或?qū)δ骋粰谟兄档臄?shù)據(jù)行數(shù)統(tǒng)計
max(字段名) 取得一個表格欄最大的值
min(字段名) 取得一個表格欄最小的值
sum(字段名) 把數(shù)據(jù)欄的值相加
引用以上函數(shù)的方法: sql="select sum(字段名) as 別名 from 數(shù)據(jù)表 where 條件表達(dá)式"
set rs=conn.excute(sql)
用 rs("別名") 獲取統(tǒng)的計值,其它函數(shù)運(yùn)用同上。
數(shù)據(jù)表的建立和刪除: create table 數(shù)據(jù)表名稱(字段1 類型1(長度),字段2 類型2(長度) …… )
例:create table tab01(name varchar(50),datetime default now())
drop table 數(shù)據(jù)表名稱 (永久性刪除一個數(shù)據(jù)表)
記錄集對象的方法:
rs.movenext 將記錄指針從當(dāng)前的位置向下移一行
rs.moveprevious 將記錄指針從當(dāng)前的位置向上移一行
rs.movefirst 將記錄指針移到數(shù)據(jù)表第一行
rs.movelast 將記錄指針移到數(shù)據(jù)表最后一行
rs.absoluteposition=n 將記錄指針移到數(shù)據(jù)表第n行
rs.absolutepage=n 將記錄指針移到第n頁的第一行
rs.pagesize=n 設(shè)置每頁為n條記錄
rs.pagecount 根據(jù) pagesize 的設(shè)置返回總頁數(shù)
rs.recordcount 返回記錄總數(shù)
rs.bof 返回記錄指針是否超出數(shù)據(jù)表首端,true表示是,false為否
rs.eof 返回記錄指針是否超出數(shù)據(jù)表末端,true表示是,false為否
rs.delete 刪除當(dāng)前記錄,但記錄指針不會向下移動
rs.addnew 添加記錄到數(shù)據(jù)表末端
rs.update 更新數(shù)據(jù)表記錄
判斷所填數(shù)據(jù)是數(shù)字型
if not isnumeric(request("字段名稱")) then
response.write "不是數(shù)字"
else
response.write "數(shù)字"
end if頁面執(zhí)行時間:
<%startime = timer()%>
.... ....
內(nèi)容
... ...
結(jié)尾
<%
dim endtime
endtime = timer()
response.write "頁面執(zhí)行時間:<font color=red>"&formatnumber((endtime-startime)*1000,5)&"</font> 毫秒"
%>定義打開網(wǎng)頁時起始窗口的大小
<script for="window" event="onload">
window.resizeto(500,300)
</script>
隨機(jī)數(shù):
<%randomize%>
<%=(int(rnd()*n)+1)%>
查詢數(shù)據(jù)時得到的記錄關(guān)鍵字用紅色顯示:
replace(rs("字段x"),searchname,"<font color=#ff0000>" & searchname & "</font>")
通過asp的手段來檢查來訪者是否用了代理
<% if request.servervariables("http_x_forwarded_for")<>"" then
response.write "<font color=#ff0000>您通過了代理服務(wù)器,"& _
"真實的ip為"&request.servervariables("http_x_forwarded_for")
end if
%>
判斷上一頁的來源
request.servervariables("http_referer")
javascript: document.referrer
清除緩存,重新加載頁面
<%response.expires = 0
response.expiresabsolute = now() - 1
response.addheader "pragma","no-cache"
response.addheader "cache-control","private"
response.cachecontrol = "no-cache"
%>
檢索并刪除數(shù)據(jù)庫里的重復(fù)記錄
conn.execute("delete from table where id not in (select distinct from table)")
文件刪除函數(shù) <%
文件刪除函數(shù)
function deletefile(filename)
if filename<>"" then
set fso=server.createobject("scripting.filesystemobject")
if fso.fileexists(filename) then
fso.deletefile filename
else
response.write "<script>alert(’該文件不存在’);</script>"
end if
end if
end function
strfile=server.mappath("filename")
deletefile(strfile)
%>
asp字?jǐn)?shù)計算函數(shù) <%
function wordcount(strinput)
dim strtemp
strtemp = replace(strinput, vbtab, " ")
strtemp = replace(strtemp, vbcr, " ")
strtemp = replace(strtemp, vblf, " ")
刪除字首字尾空格
strtemp = trim(strtemp)
替換為一個空格
do while instr(1, strtemp, " ", 1) <> 0
strtemp = replace(strtemp, " ", " ")
loop
wordcount = ubound(split(strtemp, " ", -1, 1)) +1
end function
%>全正則的檢測ip是否合法的函數(shù)
function checkip2(sipaddress)
{
var exp=/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
var reg = sipaddress.match(exp);
var errmsg="你輸入的是一個非法的ip地址段!\nip段為::xxx.xxx.xxx.xxx(xxx為0-255)!"
var msg="你輸入的是一個合法的ip地址段!"
if(reg==null)
{
alert(errmsg);
}
else
{
alert(reg);
}
}
關(guān)閉子窗口時刷新父窗口 在子窗口
<script language="javascript">
window.opener.location="父窗口頁面"
window.close()
</script>
文本框輸入限制:
<script>
function reginput(obj, reg, inputstr)
{
var docsel = document.selection.createrange()
if (docsel.parentelement().tagname != "input") return false
osel = docsel.duplicate()
osel.text = ""
var srcrange = obj.createtextrange()
osel.setendpoint("starttostart", srcrange)
var str = osel.text + inputstr + srcrange.text.substr(osel.text.length)
return reg.test(str)
}
</script>
小寫英文:<xmp style= "display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^[a-z]*$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^[a-z]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[a-z]*$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled"
><br>
大寫英文:<xmp style= "display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^[a-z]*$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^[a-z]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[a-z]*$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled">
<br>
任意數(shù)字:<xmp style="display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^[0-9]*$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^[0-9]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[0-9]*$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled"
><br>
限2位小數(shù):<xmp style="display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^\d*\.?\d{0,2}$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^\d*\.?\d{0,2}$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^\d*\.?\d{0,2}$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled"
> 如: 123.12<br>
日 期:<xmp style="display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled"
> 如: 2002-9-29<br>
任意中文:<xmp style="display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^[\u4e00-\u9fa5]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[\u4e00-\u9fa5]*$/, event.datatransfer.getdata(text))"
><br>
部分英文:<xmp style="display:inline"> </xmp>
<input onkeypress = "return reginput(this, /^[a-e]*$/, string.fromcharcode(event.keycode))"
onpaste = "return reginput(this, /^[a-e]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[a-e]*$/, event.datatransfer.getdata(text))"
style="ime-mode:disabled"
> 范圍: a,b,c,d,e<br>
部分中文:<xmp style="display:inline"> </xmp>
<script language=javascript>
function checkchinese(oldlength, obj)
{
var otr = window.document.selection.createrange()
var reg = /[^一二三四五六七八九十]/g
otr.movestart("character", -1*(obj.value.length-oldlength))
otr.text = otr.text.replace(reg, "")
}
</script>
<input onkeypress="return false" onkeydown="settimeout(checkchinese(+this.value.length+,+this.uniqueid+), 1)"
onpaste = "return reginput(this, /^[一二三四五六七八九十]*$/, window.clipboarddata.getdata(text))"
ondrop = "return reginput(this, /^[一二三四五六七八九十]*$/, event.datatransfer.getdata(text))"
> 范圍: 一二三四五六七八九十<br>
不能點右鍵,不用ctrl+a,不能復(fù)制作!
<body oncontextmenu="window.event.returnvalue=false"
onkeypress="window.event.returnvalue=false"
onkeydown="window.event.returnvalue=false"
onkeyup="window.event.returnvalue=false"
ondragstart="window.event.returnvalue=false"
onselectstart="event.returnvalue=false">
</body>
顯示狀態(tài)攔固定文字:
放在body前
<base onmouseover="window.status=這里是goaler的blog系統(tǒng),歡迎訪問;return true">
用鍵盤打開網(wǎng)頁 <script language=javascript>
document.onkeydown=gopage
var add="admin/addarticle.asp"
var logon="admin/logon.asp"
function gopage() {
if (event.keycode==13) location=add
if (event.keycode==38) location=logon
}
</script>
根據(jù)內(nèi)容自動調(diào)整iframe高度
有時為了方便使用iframe,但被潛入的頁面長度不是固定的,顯示滾動條不僅影響美觀還對用戶操作帶來不便,自動調(diào)整高度可以解決這個問題。^_^
function f_framestyleresize(targobj)
{
var targwin = targobj.parent.document.all[targobj.name];
if(targwin != null)
{
var heightvalue = targobj.document.body.scrollheight
if(heightvalue < 600){heightvalue = 600} //不小于600
targwin.style.pixelheight = heightvalue;
}
}
function f_iframeresize()
{
bloadcomplete = true;
f_framestyleresize(self);
}
var bloadcomplete = false;
window.onload = f_iframeresize;
禁止頁面正文內(nèi)容被選取
<body oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return
false"onmouseup="document.selection.empty()">
消除ie6自動出現(xiàn)的圖像工具欄,設(shè)置 galleryimg屬性為false或no .
<img src="mypicture.jpg" height="100px" width="100px" galleryimg="no">
防止點擊空鏈接時,頁面往往重置到頁首端。
代碼“javascript:void(null)”代替原來的“#”標(biāo)記
如何避免別人把你的網(wǎng)頁放在框架中
<script language=“javascript”><!--if (self!=top){top.location=self.location;} -->< /script>
頁面定時刷新
<meta http-equiv="refresh" content="秒" >
頁面定時轉(zhuǎn)向新的地址
<meta http-equiv="refresh" content="秒;url=url">
關(guān)閉窗口,這個是不會彈出提示直接關(guān)的:
把如下代碼加入<body>區(qū)域中
<object id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="command" value="close">
</object>
<script language="javascript">function shutwin(){closes.click();return;}</script>
<a href="javascript:shutwin();">關(guān)閉本窗口</a>
有時候好不容易寫出來的程序代碼被別人抄去,心里一定不好受。這還是小事,但如果在我們的源代碼中有一些不希望讓別人知道的內(nèi)容,比如密碼、action的指向等,這些一旦被人利用,那后果有時是不堪設(shè)想的。而網(wǎng)頁加密就是我們現(xiàn)在需要解決的問題。下面就我在網(wǎng)頁制作中的一些經(jīng)驗向大家介紹一些簡單的防范方法。
禁止右鍵
看到這里大家一定會想,這招有很多人介紹過了,而且破解的方法也有很多。但我這里要說的是另一種方法,而且我試了很多方法都沒有能破解。具體如下:
<html>
<head>
<script>
function stop(){
alert("試試能破解嗎?");
return false;
}
document.oncontextmenu=stop;
</script>
<boyd>你可以按右鍵、shift+f10和右ctrl左邊的那個鍵試試!看能不能解。^_^</body>
大家試試,看能不能破解!你可以將alert("試試能破解嗎?");這句去掉,這樣當(dāng)按右鍵時就什么反應(yīng)也沒有了,就好像沒有右鍵功能一樣。
禁示查看源代碼
我們已經(jīng)禁了右鍵,但從"查看"菜單下的"源文件"中同樣可以看到源代碼,下面我們就來解決這個問題:
其實這只要使用一個含有<frame></frame>標(biāo)記的網(wǎng)頁便可以達(dá)到目的。
<frameset>
<frame src="你要保密的文件的url">
</frameset>
這樣當(dāng)有人使用"查看"下的"源文件"的時候,看到的將是上面的那段代碼,而你真正的文件又躲過一劫。
禁示另存為
通過上面的兩步好像你的源代碼已經(jīng)安全了,但別忘了,別人還可以將你的頁面保存下來,再慢慢分析。不過別擔(dān)心,下面我們來解決這個問題。
在你要保密的網(wǎng)頁中加入以下代碼:
<noscript><iframe src="*.htm"></iframe></noscript>
徹底屏蔽右鍵方法。
<body oncontextmenu="return false">
雙擊頁面后自動滾屏,單擊后停止。
<script language=javascript>
var currentpos,timer;
function initialize()
{ timer=setinterval("scrollwindow()",16); }
function sc(){
clearinterval(timer);
}
function scrollwindow()
{currentpos=document.body.scrolltop;
window.scroll(0,++currentpos);
if (currentpos != document.body.scrolltop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
設(shè)定腳本出錯能繼續(xù)運(yùn)行
<script language="javascript">
function killerror()
{
return false;
}
window.onerror=killerror;
</script>
將徹底屏蔽鼠標(biāo)右鍵
oncontextmenu="window.event.returnvalue=false"
可用于table
<table border oncontextmenu=return(false)><td>no</table>
取消選取、防止復(fù)制
<body onselectstart="return false">
不準(zhǔn)粘貼
onpaste="return false"
防止復(fù)制
oncopy="return false;" oncut="return false;"
ie地址欄前換成自己的圖標(biāo)
<link rel="shortcut icon" href="favicon.ico">
可以在收藏夾中顯示出你的圖標(biāo)
<link rel="bookmark" href="favicon.ico">
關(guān)閉輸入法
<input style="ime-mode:disabled">
永遠(yuǎn)都會帶著框架
<script language="javascript"><!--
if (window == top)top.location.href = "frames.htm";
//frames.htm為框架網(wǎng)頁
// -->
</script>
防止被人frame
<script language=javascript><!--
if (top.location != self.location)
top.location=self.location;
// -->
</script>
怎樣通過asp的手段來檢查來訪者是否用了代理
<% if request.servervariables("http_x_forwarded_for")<>"" then
response.write "<font color=#ff0000>您通過了代理服務(wù)器," & "真實的ip為 "&request.servervariables("http_x_forwarded_for")
end if
%>
取得控件的絕對位置
//javascript
<script language="javascript">
function getie(e){
var t=e.offsettop;
var l=e.offsetleft;
while(e=e.offsetparent){
t+=e.offsettop;
l+=e.offsetleft;
}
alert("top="+t+"nleft="+l);
}
</script>
//vbscript
<script language="vbscript">
<!--
function getie()
dim t,l,a,b
set a=document.all.img1
t=document.all.img1.offsettop
l=document.all.img1.offsetleft
while a.tagname<>"body"
set a = a.offsetparent
t=t+a.offsettop
l=l+a.offsetleft
wend
msgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"
end function
-->
</script>
光標(biāo)是停在文本框文字的最后
<script language="javascript">
function cc()
{
var e = event.srcelement;
var r =e.createtextrange();
r.movestart(character,e.value.length);
r.collapse(true);
r.select();
}
</script>
<input type=text name=text1 value="123" onfocus="cc()">
判斷上一頁的來源
asp:
request.servervariables("http_referer")
javascript:
document.referrer
最小化、最大化、關(guān)閉窗口
<object id=hh1 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="command" value="minimize"></object>
<object id=hh2 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="command" value="maximize"></object>
<object id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="command" value="close"></object>
<input type=button value=最小化 onclick=hh1.click()>
<input type=button value=最大化 onclick=hh2.click()>
<input type=button value=關(guān)閉 onclick=hh3.click()>
本例適用于ie
記錄并顯示網(wǎng)頁的最后修改時間
<script language=javascript>
document.write("最后更新時間: " + document.lastmodified + "")
</script>
2秒后關(guān)閉當(dāng)前頁
<script language="javascript">
<!--
settimeout(window.close();,2000);
-->
</script>
2秒后載入指定網(wǎng)頁
<head>
<meta http-equiv="refresh" content="2;url=http://你的網(wǎng)址">
</head>
添加到收藏夾
<script language="javascript">
function bookmarkit()
{
window.external.addfavorite(http://你的網(wǎng)址,你的網(wǎng)站名稱)
}
if (document.all)document.write(<a href="#" onclick="bookmarkit()">加入收藏夾</a>)
</script>
禁止鼠標(biāo)右鍵的動作
<script language = "javascript">
function click() { if (event.button==2||event.button==3)
{
alert(禁止鼠標(biāo)右鍵);
}
document.onmousedown=click // -->
</script>
或
<script language="javascript">
function click() { if (event.button==2)
{alert(*^_^*); } } document.onmousedown=click // -->
</script>
設(shè)置該頁為首頁
<body bgcolor="#ffffff" text="#000000">
<a class="chlnk" style="cursor:hand" href onclick="this.style.behavior=url(#default#homepage); this.sethomepage(你的網(wǎng)站名稱);"><font color="000000" size="2" face="宋體">設(shè)為首頁</font></a>
</body>
節(jié)日倒計時
<script language="javascript">
var timedate= new date("october 1,2002");
var times="國慶節(jié)";
var now = new date();
var date = timedate.gettime() - now.gettime();
var time = math.floor(date / (1000 * 60 * 60 * 24));
if (time >= 0)
document.write("現(xiàn)在離"+times+"還有: "+time +"天")
</script>
單擊按鈕打印出當(dāng)前頁
<script language="javascript">
if (window.print) {
document.write(<form>
+ <input type=button name=print value="打印本頁"
+ onclick="javascript:window.print()"></form>);
}
</script>
單擊按鈕‘另存為’當(dāng)前頁
<input type="button" name="button" value="保存本頁" onclick="document.all.button.execwb(4,1)">
<object id="button" width=0 height=0 classid="clsid:8856f961-340a-11d0-a96b-00c04fd705a2">
<embed width="0" height="0"></embed>
</object>
顯示系統(tǒng)當(dāng)前日期
<script language=javascript>
today=new date();
function date(){
this.length=date.arguments.length
for(var i=0;i<this.length;i++)
this[i+1]=date.arguments }
var d=new date("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write(
"<font color=##000000 style=font-size:9pt;font-family: 宋體> ",
today.getyear(),"年",today.getmonth()+1,"月",today.getdate(),"日",
d[today.getday()+1],"</font>" );
</script>
不同時間段顯示不同問候語 <script language="javascript">
var text=""; day = new date( ); time = day.gethours( );
if (( time>=0) && (time < 7 ))
text="夜貓子,要注意身體哦! "
if (( time >= 7 ) && (time < 12))
text="今天的陽光真燦爛啊,你那個朋友呢?"
if (( time >= 12) && (time < 14))
text="午休時間。您要保持睡眠哦!"
if (( time >=14) && (time < 18))
text="祝您下午工作愉快! "
if ((time >= 18) && (time <= 22))
text="您又來了,可別和mm聊太久哦!"
if ((time >= 22) && (time < 24))
text="您應(yīng)該休息了!"
document.write(text)
</script>
水中倒影效果 <img id="reflect" src="你自己的圖片文件名" width="175" height="59">
<script language="javascript">
function f1()
{
setinterval("mdiv.filters.wave.phase+=10",100);
}
if (document.all)
{
document.write(<img id=mdiv src="+document.all.reflect.src+"
style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30) blur() flipv()">)
window.onload=f1
}
</script>
慢慢變大的窗口 <script language="javascript">
<!--
var windowsheight=100
var windowswidth=100
var numx=5
function openwindow(thelocation){
temploc=thelocation&, amp;, nbsp;
if
(!(window.resizeto&&document.all)&&!(window.resizeto&&document.getelementbyid))
{
window.open(thelocation)
return
}
windowsize=window.open("","","scrollbars")
windowsize.moveto(0,0)
windowsize.resizeto(100,100)
tenumxt()
}
function tenumxt(){
if (windowsheight>=screen.availheight-3)
numx=0
windowsize.resizeby(5,numx)
windowsheight+=5
windowswidth+=5
if (windowswidth>=screen.width-5)
{
windowsize.location=temploc
windowsheight=100
windowswidth=100
numx=5
return
}
settimeout("tenumxt()",50)
}
//-->
</script>
<a href="javascript:openwindow(http://www.ccjol.com)">進(jìn)入</a>
鼠標(biāo)指向時彈出信息框
在<body></body>之間加上如下代碼: <a href onmouseover="alert(彈出信息!)">顯示的鏈接文字</a>
隨機(jī)變換背景圖象(一個可以刷新心情的特效)
在<head></head>之間加上如下代碼:
<script language="javascript">
image = new array(4); //定義image為圖片數(shù)量的數(shù)組
image [0] = tu0.gif //背景圖象的路徑
image [1] = tu1.gif
image [2] = tu2.gif
image [3] = tu3.gif
image [4] = tu4.gif
number = math.floor(math.random() * image.length);
document.write("<body background="+image[number]+">");
</script>
鼠標(biāo)一碰就給顏色看的鏈接 在<body></body>之間加上如下代碼:
<p onmousemove="anniu()">你敢碰我,我就給點顏色你看!</p>
<script language = "vbscript">
sub anniu
document.fgcolor=int(256*256*256*rnd)
end sub
</script>
從天而降并有幻影效果的窗口
<head>
<script language="javascript">
function move(x) {
if(self.moveby){
self.moveby (0,-800);
for(i = x; i > 0; i--)
{
self.moveby(0,3);
}
for(j = 200; j > 0; j--){ //如果你認(rèn)為窗口抖動厲害,就200換成個位數(shù)
self.moveby(0,j);
self.moveby(j,0);
self.moveby(0,-j);
self.moveby(-j,0);
}
}
}
</scrip>
<body bgcolor=#ffffff onload=move(280)>
</body>
</head>
表格的半透明顯示效果 在<head></head>之間加上如下代碼:
<style>
.alpha{filter: alpha(opacity=50)} //50表示50%的透明度
</style>
在<body></body>之間加上如下代碼:
<table border="1" width="100" height="62" class="alpha" bgcolor="#f2a664" >
<tr>
<td width="100%" height="62">
<div align="center">很酷吧!</div>
</td>
</tr>
</table>
鎖定狀態(tài)欄文字防止顯示地址
<body onmouseover="self.status=文字;return true">
禁止圖片下載
在<body......>這里的最后加入:
oncontextmenu="return false" ondragstart="return false" onselectstart="return false" scroll="auto"
禁止緩存
<meta http-equiv="expires" content="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="pragma" content="no-cache">
加在head里
使用包含頁面
加密所包含頁面地址,使用工具 htmlguardian5.3.5
目前功能最強(qiáng)的html代碼加密軟件,可以保護(hù)連接和html代碼被盜。1.鎖右鍵。2.禁鼠標(biāo)圈選。3.不允許離線使用。4.密碼保護(hù)。5.不顯示狀態(tài)欄url地址。6.全代碼 或 局部代碼保護(hù)。7.鏈接跟蹤。8.禁止打印(ie5+)。9.壓縮代碼( 未加密前)。10.可加密*.html *.js *.asp *.vbs。11.兩種不同加密算法。12.加密 frameset 結(jié)構(gòu)。13.某些功能支持幾個不同版本的瀏覽器。
下載flash我的三種方法:
--查看源文件,找出flash的絕對路徑,復(fù)制,在flashget(或螞蟻)中點任務(wù)
,然后點新建下載任務(wù)即可。
--在ie的臨時文件夾temporary internet files里把所有的東西都刪掉,然后
刷新你想要下載flash的網(wǎng)頁,即可得到你所要的flash
--使用外部軟件,推薦使用flash catcher,安裝后只需在你所要下載的flash上右鍵,save即可。
讓iframe框架內(nèi)的文檔的背景透明
<iframe src="about:<body style=background:transparent>" allowtransparency></iframe>
進(jìn)入頁面后立即自動刷新?
<meta http-equiv="refresh" content="120;url=http://www.wodutom.com/cn083">
http://www.wodutom.com/cn083,這是你自己的網(wǎng)址。
打開窗口即最大化
<script language="javascript">
<!-- begin
self.moveto(0,0)
self.resizeto(screen.availwidth,screen.availheight)
// end -->
</script>
能隱藏iframe的滾動條嗎?我知道的三種方法:
1. 設(shè)置iframe scrolling="no"
2. 被包含頁body應(yīng)用overflow:hidden
3. 被包含頁的body標(biāo)簽加scroll="no"
加入背景音樂
<bgsound src="mid/windblue[1].mid" loop="-1"> 只適用于ie
<embed src="music.mid" autostart="true" loop="true" hidden="true">
對netscape ,ie 都適用
嵌入網(wǎng)頁
<iframe name="tt" src="01a.html" width="450" height="287" scrolling="auto" frameborder="0"></iframe>
跳轉(zhuǎn)
<meta http-equiv="refresh" content="3;url=list.htm">
滾動
<marquee direction=up height=146 onmouseout=start() onmouseover=stop() scrollamount=4>
</marquee>
細(xì)線分隔線
<hr noshade size=0 color=#c0c0c0>
過度方式
<meta http-equiv="page-exit" content="revealtrans(duration=3,transition=5)">
duration的值為網(wǎng)頁動態(tài)過渡的時間,單位為秒。
transition是過渡方式,它的值為0到23,分別對應(yīng)24種過渡方式。如下表:
0 盒狀收縮 1 盒狀放射
2 圓形收縮 3 圓形放射
4 由下往上 5 由上往下
6 從左至右 7 從右至左
8 垂直百葉窗 9 水平百葉窗
10 水平格狀百葉窗 11垂直格狀百葉窗
12 隨意溶解 13從左右兩端向中間展開
14從中間向左右兩端展開 15從上下兩端向中間展開
16從中間向上下兩端展開 17 從右上角向左下角展開
18 從右下角向左上角展開 19 從左上角向右下角展開
20 從左下角向右上角展開 21 水平線狀展開
22 垂直線狀展開 23 隨機(jī)產(chǎn)生一種過渡方式
如何控制橫向和縱向滾動條的顯隱?
<body style="overflow-y:hidden"> 去掉x軸
<body style="overflow-x:hidden"> 去掉y軸
<body scroll="no">不顯
定義本網(wǎng)頁關(guān)鍵字,可以在<head></head>中加入如下代碼: <meta name="keywords" content="china,enterprise,business,net"> content 中所包含的就是關(guān)鍵字,你可以自行設(shè)置。
這里有個技巧,你可以重復(fù)某一個單詞,這樣可以提高自己網(wǎng)站的排行位置,如:
<meta name="keywords" content="china,china,china,china">
ie5.0 的部分快捷鍵:
a:打開查找功能:ctrl+f
關(guān)閉瀏覽器窗口:ctrl+w
打開地址欄下拉列表框:f4
刷 新:f5
將當(dāng)前web頁保存到收藏夾列表:ctrl+d
打開當(dāng)前 ie 窗口的一個拷貝:ctrl+n
停止下載當(dāng)前網(wǎng)頁:esc
光標(biāo)迅速移動到網(wǎng)頁的開頭:home
光標(biāo)迅速移動到網(wǎng)頁的尾部:end
打開新的地址鍵入窗口:ctrl+o
打開收藏夾:ctrl+i
打開歷史記錄文件夾:ctrl+h
打開瀏覽器設(shè)定的默認(rèn)主頁:alt+home
添加到收藏夾:
<a href="javascript:window.external.addfavorite(http://鏈接,說明);">添加到收藏夾</a>
設(shè)為首頁:
<a href=# onclick=this.style.behavior=url(#default#homepage);this.sethomepage (http://鏈接);>設(shè)為首頁</a>
定制瀏覽器地址欄前的小圖標(biāo):
a:在網(wǎng)頁的<head></head>間加入以下語句
<link rel="shortcuticon" href="http://…/icon.ico">
即可。其中 icon.ico 為 16x16 的圖標(biāo)文件,
顏色不要超過 16 色。
把滾動條放在瀏覽器窗口的左邊
a:在 <body> 中加 dir=rtl,即 <body dir=rtl>。
讓背景圖不滾動
ie瀏覽器支持一個 body 屬性 bgproperties,它可以讓背景不滾動:
<body background="圖片文件" bgproperties="fixed">
刪除確認(rèn):
<input type="button" name="del" onclick="{if(confirm(確認(rèn)刪除么?)){location.href=xxx.asp;}return false;}" value="on" >
隱藏狀態(tài)欄中的鏈接地址:
<script language="javascript">
kstatus();
function kstatus(){
self.status="gblog () ";
settimeout("kstatus()",0);
}
</script>自定義指定區(qū)域的文字大?。?br><div id=zoom>sdrrrrrrrrrrrrrrrrrrrrrrrrrrrrr</div>
【<a href="javascript:dozoom(16)">大</a> <a href="javascript:dozoom(14)">中</a> <a href="javascript:dozoom(12)">小</a>】
<script language=javascript>
function dozoom(size){
document.getelementbyid(zoom).style.fontsize=size+px
}
</script>
input輸入框文字效果:
<input type="text" value="123456" style="font-size:38px;color:red;font-family:arial black">通過層來實現(xiàn)漸淡淡出
<script language="javascript1.2">
function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=50
}
</script>
<div style="width:200px;height:200px;filter:alpha(opacity=50);border:1px solid #000;background:#efefef" onmouseover="makevisible(this,0)" onmouseout="makevisible(this,1)">
ywicc.com
</div>
網(wǎng)頁屏保
<script language="javascript">
function screensave(){
test.value++;
if(test.value==5){
test.style.display=none;
document.all[4].bgcolor=black;
}
}
function screenopen(){
test.value=0;
test.style.display=;
document.all[4].bgcolor=;
}
</script>
<body onkeydown="screenopen()" onmousemove="screenopen()" onload="setinterval(screensave(),1000)">
5 秒屏保<input id="test">
讓標(biāo)題動態(tài)
<script>
<!--
var tx = new array (
"◇:::::::網(wǎng)頁制作學(xué)習(xí)園地:::::::◇歡迎您!◇",
"◆歡迎大家光臨網(wǎng)頁制作學(xué)習(xí)園地網(wǎng)站!◆",
"◆大量供應(yīng)網(wǎng)頁制作教材,資料,源代碼,網(wǎng)頁制作軟件,相關(guān)插件光盤!◆",
"◆最可怕的敵人,就是沒有堅強(qiáng)的信念!◆",
"◆應(yīng)該讓別人的生活因為有了你的生存而更加美好!◆"
);
var txcount=5;
var i=1;
var wo=0;
var ud=1;
function animatetitle()
{
window.document.title=tx[wo].substr(0, i)+"_";
if (ud==0) i--;
if (ud==1) i++;
if (i==-1) {ud=1;i=0;wo++;wo=wo%txcount;}
if (i==tx[wo].length+10) {ud=0;i=tx[wo].length;}
// if (window.document.title.length < 20 ) window.document.title=window.document.title+"-";
// if (window.document.title.length == 20 ) window.document.title=window.document.title+"]";
// if (window.document.title.length == 21 ) settimeout("window.document.title=animierte seitentitel ; ",1000);
parent.window.document.title=tx[wo].substr(0, i)+"_";
settimeout("animatetitle()",100);
}
animatetitle();
// --></script><script language="javascript">
<!--
function mm_openbrwindow(theurl,winname,features) { //v2.0
window.open(theurl,winname,features);
}
//-->
</script>
隱去瀏覽器中當(dāng)鼠標(biāo)移到圖片上跳出的工具欄
<img galleryimg="no">
或者
<head>
<meta http-equiv="imagetoolbar" content="no">
</head>
在form中只有input輸入框的情況下...在這個input輸入框中按enter進(jìn)行提交表單
<form onsubmit="if(event.srcelement.name==bb){this.submit()}else{return false}">
<input name=a size=20>
<input type=button name=bb onclick="submit();">
</form>
刪除確認(rèn)
<input type="button" value="刪除" onclick="{if(confirm(確認(rèn)刪除么?)){location.href=aa.asp;}return false;}">或
<a href="aa.asp" onclick="{if(confirm(確定刪除嗎?)){return true;}return false;}">刪除</a> 或
<a href="del.asp" onclick="return confirm(該刪除操作將無法恢復(fù)!是否繼續(xù)?)">刪除</a>
返回頁面頂部:
javascript:window.scroll(0,0)
離開頁面時彈出警告:
<body onbeforeunload="checkclose()">
<script>
function checkclose(){
event.returnvalue = "測試啊" //xxx可以改為任何文本信息也可以是空
}
</script>
<a href="a.asp">aa</a>