




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1/36WEB編程開發(fā)常用的代碼--
最小化、最大化、關(guān)閉窗口
<objectid=hh1classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<paramname="Command"value="Minimize"></object>
<objectid=hh2classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11">
<paramname="Command"value="Maximize"></object>
<OBJECTid=hh3classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<PARAMNAME="Command"value="Close"></OBJECT>
<inputtype=buttonvalue=最小化onclick=hh1.Click()>
<inputtype=buttonvalue=最大化onclick=hh2.Click()>
<inputtype=buttonvalue=關(guān)閉onclick=hh3.Click()>
本例適用于IE
記錄并顯示網(wǎng)頁的最后修改時(shí)間
<scriptlanguage=JavaScript>
document.write("最后更新時(shí)間:"+document.lastModified+"")
</script>
2秒后關(guān)閉當(dāng)前頁
<scriptlanguage="JavaScript">
<!--
setTimeout('window.close();',2000);
-->
</script>
2秒后載入指定網(wǎng)頁
<head>
<metahttp-equiv="refresh"content="2;URL=http://你的網(wǎng)址">
</head>
添加到收藏夾
<ScriptLanguage="JavaScript">
functionbookmarkit()
{
window.external.addFavorite('http://你的網(wǎng)址','你的網(wǎng)站名稱')
}
if(document.all)document.write('<ahref="#"onClick="bookmarkit()">加入收藏夾</a>')
</Script>
禁止鼠標(biāo)右鍵的動(dòng)作
<ScriptLanguage="JavaScript">
functionclick(){if(event.button==2||event.button==3)
{
alert('禁止鼠標(biāo)右鍵');
}
document.onmousedown=click//-->
</Script>
或
<scriptlanguage="JavaScript">
functionclick(){if(event.button==2)
{alert('*^_^*');}}document.onmousedown=click//-->
</script>
設(shè)置該頁為首頁
<bodybgcolor="#FFFFFF"text="#000000">
<aclass="chlnk"style="cursor:hand"HREFonClick="this.style.behavior='url(#default#homepage)';this.setHomePage('你的網(wǎng)站名稱);"><fontcolor="000000"size="2"face="宋體">設(shè)為首頁</font></a>
</body>
節(jié)日倒計(jì)時(shí)
<ScriptLanguage="JavaScript">
vartimedate=newDate("October1,2002");
vartimes="國慶節(jié)";
varnow=newDate();
vardate=timedate.getTime()-now.getTime();
vartime=Math.floor(date/(1000*60*60*24));
if(time>=0)
document.write("現(xiàn)在離"+times+"還有:"+time+"天")
</Script>
單擊按鈕打印出當(dāng)前頁
<ScriptLanguage="JavaScript">
if(window.print){
document.write('<form>'
+'<inputtype=buttonname=printvalue="打印本頁"'
+'onClick="javascript:window.print()"></form>');
}
</Script>
單擊按鈕‘另存為’當(dāng)前頁
<inputtype="button"name="Button"value="保存本頁"onClick="document.all.button.ExecWB(4,1)">
<objectid="button"width=0height=0classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
<embedwidth="0"height="0"></embed>
</object>
顯示系統(tǒng)當(dāng)前日期
<scriptlanguage=JavaScript>
today=newDate();
functiondate(){
this.length=date.arguments.length
for(vari=0;i<this.length;i++)
this[i+1]=date.arguments}
vard=newdate("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
document.write(
"<fontcolor=##000000style='font-size:9pt;font-family:宋體'>",
today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",
d[today.getDay()+1],"</font>");
</script>
不同時(shí)間段顯示不同問候語<ScriptLanguage="JavaScript">
vartext="";day=newDate();time=day.getHours();
if((time>=0)&&(time<7))
text="夜貓子,要注意身體哦!"
if((time>=7)&&(time<12))
text="今天的陽光真燦爛啊,你那個(gè)朋友呢?"
if((time>=12)&&(time<14))
text="午休時(shí)間。您要保持睡眠哦!"
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>
水中倒影效果<imgid="reflect"src="你自己的圖片文件名"width="175"height="59">
<scriptlanguage="JavaScript">
functionf1()
{
setInterval("mdiv.filters.wave.phase+=10",100);
}
if(document.all)
{
document.write('<imgid=mdivsrc="'+document.all.reflect.src+'"
style="filter:wave(strength=3,freq=3,phase=0,lightstrength=30)blur()flipv()">')
window.onload=f1
}
</script>
慢慢變大的窗口<ScriptLanguage="JavaScript">
<!--
varWindowsheight=100
varWindowswidth=100
varnumx=5
functionopenwindow(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()
}
functiontenumxt(){
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>
<ahref="javascript:openwindow('')">進(jìn)入</a>
鼠標(biāo)指向時(shí)彈出信息框
在<body></body>之間加上如下代碼:<ahrefonmouseover="alert('彈出信息!')">顯示的鏈接文字</a>
隨機(jī)變換背景圖象(一個(gè)可以刷新心情的特效)
在<head></head>之間加上如下代碼:
<ScriptLanguage="JavaScript">
image=newArray(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("<BODYBACKGROUND="+image[number]+">");
</Script>
鼠標(biāo)一碰就給顏色看的鏈接在<body></body>之間加上如下代碼:
<ponMouseMove="anniu()">你敢碰我,我就給點(diǎn)顏色你看!</p>
<ScriptLanguage="VBScript">
subanniu
document.fgColor=int(256*256*256*rnd)
endsub
</Script>
從天而降并有幻影效果的窗口
<head>
<Scriptlanguage="JavaScript">
functionmove(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)為窗口抖動(dòng)厲害,就200換成個(gè)位數(shù)
self.moveBy(0,j);
self.moveBy(j,0);
self.moveBy(0,-j);
self.moveBy(-j,0);
}
}
}
</Scrip>
<bodybgColor=#ffffffonload=move(280)>
</body>
</head>
表格的半透明顯示效果在<head></head>之間加上如下代碼:
<style>
.alpha{filter:Alpha(Opacity=50)}//50表示50%的透明度
</style>
在<body></body>之間加上如下代碼:
<tableborder="1"width="100"height="62"class="alpha"bgcolor="#F2A664">
<tr>
<tdwidth="100%"height="62">
<divalign="center">很酷吧!</div>
</td>
</tr>
</table>
鎖定狀態(tài)欄文字防止顯示地址
<bodyonmouseover="self.status='文字';returntrue">
禁止圖片下載
在<body>這里的最后加入:
oncontextmenu="returnfalse"ondragstart="returnfalse"onselectstart="returnfalse"scroll="auto"
禁止緩存
<metahttp-equiv="Expires"CONTENT="0">
<metahttp-equiv="Cache-Control"CONTENT="no-cache">
<metahttp-equiv="Pragma"CONTENT="no-cache">
加在HEAD里
使用包含頁面
加密所包含頁面地址,使用工具h(yuǎn)tmlguardian5.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.某些功能支持幾個(gè)不同版本的瀏覽器。
下載flash我的三種方法:
--查看源文件,找出flash的絕對(duì)路徑,復(fù)制,在flashget(或螞蟻)中點(diǎn)任務(wù)
,然后點(diǎn)新建下載任務(wù)即可。
--在IE的臨時(shí)文件夾TemporaryInternetFiles里把所有的東西都刪掉,然后
刷新你想要下載flash的網(wǎng)頁,即可得到你所要的flash
--使用外部軟件,推薦使用FlashCatcher,安裝后只需在你所要下載的flash上右鍵,save即可。
讓IFRAME框架內(nèi)的文檔的背景透明
<iframesrc="about:<bodystyle='background:transparent'>"allowtransparency></iframe>
進(jìn)入頁面后立即自動(dòng)刷新?
<metahttp-equiv="refresh"content="120;url=/cn083">
/cn083,這是你自己的網(wǎng)址。
打開窗口即最大化
<scriptlanguage="JavaScript">
<!--Begin
self.moveTo(0,0)
self.resizeTo(screen.availWidth,screen.availHeight)
//End-->
</script>
能隱藏IFRAME的滾動(dòng)條嗎?我知道的三種方法:
1.設(shè)置iframescrolling="no"
2.被包含頁body應(yīng)用overflow:hidden
3.被包含頁的body標(biāo)簽加scroll="no"
加入背景音樂
<bgsoundsrc="mid/windblue[1].mid"loop="-1">只適用于IE
<embedsrc="music.mid"autostart="true"loop="true"hidden="true">
對(duì)Netscape,IE都適用
嵌入網(wǎng)頁
<iframename="tt"src="01a.html"width="450"height="287"scrolling="Auto"frameborder="0"></iframe>
跳轉(zhuǎn)
<metahttp-equiv="refresh"content="3;URL=list.htm">
滾動(dòng)
<MARQUEEdirection=upheight=146onmouseout=start()onmouseover=stop()scrollAmount=4>
</marquee>
細(xì)線分隔線
<hrnoshadesize=0color=#C0C0C0>
過度方式
<metahttp-equiv="Exit"content="revealTrans(Duration=3,Transition=5)">
Duration的值為網(wǎng)頁動(dòng)態(tài)過渡的時(shí)間,單位為秒。
Transition是過渡方式,它的值為0到23,分別對(duì)應(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)生一種過渡方式
如何控制橫向和縱向滾動(dòng)條的顯隱?
<bodystyle="overflow-y:hidden">去掉x軸
<bodystyle="overflow-x:hidden">去掉y軸
<bodyscroll="no">不顯
定義本網(wǎng)頁關(guān)鍵字,可以在<Head></Head>中加入如下代碼:<metaname="Keywords"content="china,enterprise,business,net">Content中所包含的就是關(guān)鍵字,你可以自行設(shè)置。
這里有個(gè)技巧,你可以重復(fù)某一個(gè)單詞,這樣可以提高自己網(wǎng)站的排行位置,如:
<metaname="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窗口的一個(gè)拷貝:Ctrl+N
停止下載當(dāng)前網(wǎng)頁:Esc
光標(biāo)迅速移動(dòng)到網(wǎng)頁的開頭:Home
光標(biāo)迅速移動(dòng)到網(wǎng)頁的尾部:End
打開新的地址鍵入窗口:Ctrl+O
打開收藏夾:Ctrl+I
打開歷史記錄文件夾:Ctrl+H
打開瀏覽器設(shè)定的默認(rèn)主頁:Alt+HOME
添加到收藏夾:
<ahref="javascript:window.external.addFavorite('http://鏈接','說明');">添加到收藏夾</a>
設(shè)為首頁:
<ahref=#onclick=this.style.behavior='url(#default#homepage)';this.setHomePage('http://鏈接');>設(shè)為首頁</a>
定制瀏覽器地址欄前的小圖標(biāo):
A:在網(wǎng)頁的<head></head>間加入以下語句
<linkrel="shortcuticon"href="http://…/icon.ico">
即可。其中icon.ico為16x16的圖標(biāo)文件,
顏色不要超過16色。
把滾動(dòng)條放在瀏覽器窗口的左邊
A:在<body>中加dir=RTL,即<bodydir=RTL>。
讓背景圖不滾動(dòng)
IE瀏覽器支持一個(gè)Body屬性bgproperties,它可以讓背景不滾動(dòng):
<BodyBackground="圖片文件"bgproperties="fixed">
刪除確認(rèn):
<inputtype="button"name="DEL"onclick="{if(confirm('確認(rèn)刪除么?')){location.href='xxx.asp';}returnfalse;}"value="ON">
隱藏狀態(tài)欄中的鏈接地址:
<scriptlanguage="javascript">
kstatus();
functionkstatus(){
self.status="GBlog()";
setTimeout("kstatus()",0);
}
</script>自定義指定區(qū)域的文字大?。?/p>
<divid=zoom>sdrrrrrrrrrrrrrrrrrrrrrrrrrrrrr</div>
【<Ahref="javascript:doZoom(16)">大</A><Ahref="javascript:doZoom(14)">中</A><Ahref="javascript:doZoom(12)">小</A>】
<SCRIPTlanguage=JavaScript>
functiondoZoom(size){
document.getElementById('zoom').style.fontSize=size+'px'
}
</script>
Input輸入框文字效果:
<inputtype="text"value="123456"style="FONT-size:38px;color:red;font-family:arialblack">通過層來實(shí)現(xiàn)漸淡淡出
<scriptlanguage="JavaScript1.2">
functionmakevisible(cur,which){
if(which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=50
}
</script>
<divstyle="width:200px;height:200px;filter:alpha(opacity=50);border:1pxsolid#000;background:#efefef"onMouseOver="makevisible(this,0)"onMouseOut="makevisible(this,1)">
</div>
網(wǎng)頁屏保
<scriptlanguage="JavaScript">
functionscreensave(){
test.value++;
if(test.value==5){
test.style.display='none';
document.all[4].bgColor='black';
}
}
functionscreenopen(){
test.value=0;
test.style.display='';
document.all[4].bgColor='';
}
</script>
<bodyonkeydown="screenopen()"onmousemove="screenopen()"onload="setInterval('screensave()',1000)">
5秒屏保<inputid="test">
讓標(biāo)題動(dòng)態(tài)
<script>
<!--
vartx=newArray(
"
:::::::網(wǎng)頁制作學(xué)習(xí)園地:::::::
歡迎您!
",
"◆歡迎大家光臨網(wǎng)頁制作學(xué)習(xí)園地網(wǎng)站!◆",
"◆大量供應(yīng)網(wǎng)頁制作教材,資料,源代碼,網(wǎng)頁制作軟件,相關(guān)插件光盤!◆",
"◆最可怕的敵人,就是沒有堅(jiān)強(qiáng)的信念!◆",
"◆應(yīng)該讓別人的生活因?yàn)橛辛四愕纳娑用篮?◆"
);
vartxcount=5;
vari=1;
varwo=0;
varud=1;
functionanimatetitle()
{
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='AnimierteSeitentitel';",1000);
parent.window.document.title=tx[wo].substr(0,i)+"_";
setTimeout("animatetitle()",100);
}
animatetitle();
//--></script><scriptlanguage="JavaScript">
<!--
functionMM_openBrWindow(theURL,winName,features){//v2.0
window.open(theURL,winName,features);
}
//-->
</script>
隱去瀏覽器中當(dāng)鼠標(biāo)移到圖片上跳出的工具欄
<imggalleryimg="no">
或者
<head>
<metahttp-equiv="imagetoolbar"content="no">
</head>
在form中只有input輸入框的情況下...在這個(gè)input輸入框中按enter進(jìn)行提交表單
<formonsubmit="if(event.srcE=='bb'){this.submit()}else{returnfalse}">
<inputname=asize=20>
<inputtype=buttonname=bbonclick="submit();">
</form>
刪除確認(rèn)
<inputtype="button"value="刪除"onclick="{if(confirm('確認(rèn)刪除么?')){location.href='aa.asp';}returnfalse;}">或
<ahref="aa.asp"onclick="{if(confirm('確定刪除嗎?')){returntrue;}returnfalse;}">刪除</a>或
<ahref="del.asp"onclick="returnconfirm('該刪除操作將無法恢復(fù)!是否繼續(xù)?')">刪除</a>
返回頁面頂部:
javascript:window.scroll(0,0)
離開頁面時(shí)彈出警告:
<BODYonbeforeunload="checkclose()">
<SCRIPT>
functioncheckclose(){
event.returnValue="測試啊"http://XXX可以改為任何文本信息也可以是空
}
</SCRIPT>
<ahref="a.asp">aa</a>
12:58|固定鏈接|評(píng)論(0)|引用通告(0)|記錄它
固定鏈接關(guān)閉
/members/leoshadow/Blog/cns!1pFRxBAnVKeR6dGl5PnqbCgg!121.entry
WEB編程開發(fā)常用的代碼1
1.ASP與Access數(shù)據(jù)庫連接:
dimconn,mdbfile
mdbfile=server.mappath("數(shù)據(jù)庫名稱.mdb")
setconn=server.createobject("adodb.connection")
'conn.open"driver={microsoftaccessdriver(*.mdb)};uid=admin;pwd=數(shù)據(jù)庫密碼;dbq="&mdbfile
conn.open"Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&mdbfile
2.ASP與SQL數(shù)據(jù)庫連接:dimconn
setconn=server.createobject("ADODB.connection")
con.open"PROVIDER=SQLOLEDB;DATASOURCE=SQL服務(wù)器名稱或IP地址;UID=sa;PWD=數(shù)據(jù)庫密碼;DATABASE=數(shù)據(jù)庫名稱;"
建立記錄集對(duì)象:setrs=server.createobject("adodb.recordset")
rs.openSQL語句,conn,3,2
SQL常用命令使用方法:
數(shù)據(jù)記錄篩選:sql="select*from數(shù)據(jù)表where字段名=字段值orderby字段名"
sql="select*from數(shù)據(jù)表where字段名like‘%字段值%‘orderby字段名"
sql="selecttop10*from數(shù)據(jù)表where字段名orderby字段名"
sql="select*from數(shù)據(jù)表where字段名in(‘值1‘,‘值2‘,‘值3‘)"
sql="select*from數(shù)據(jù)表where字段名between值1and值2"更新數(shù)據(jù)記錄:sql="update數(shù)據(jù)表set字段名=字段值where條件表達(dá)式"
sql="update數(shù)據(jù)表set字段1=值1,字段2=值2……字段n=值nwhere條件表達(dá)式"
刪除數(shù)據(jù)記錄:sql="deletefrom數(shù)據(jù)表where條件表達(dá)式"
sql="deletefrom數(shù)據(jù)表"(將數(shù)據(jù)表所有記錄刪除)
添加數(shù)據(jù)記錄:sql="insertinto數(shù)據(jù)表(字段1,字段2,字段3…)valuess(值1,值2,值3…)"
sql="insertinto目標(biāo)數(shù)據(jù)表select*from源數(shù)據(jù)表"(把源數(shù)據(jù)表的記錄添加到目標(biāo)數(shù)據(jù)表)數(shù)據(jù)記錄統(tǒng)計(jì)函數(shù):
AVG(字段名)得出一個(gè)表格欄平均值
COUNT(*|字段名)對(duì)數(shù)據(jù)行數(shù)的統(tǒng)計(jì)或?qū)δ骋粰谟兄档臄?shù)據(jù)行數(shù)統(tǒng)計(jì)
MAX(字段名)取得一個(gè)表格欄最大的值
MIN(字段名)取得一個(gè)表格欄最小的值
SUM(字段名)把數(shù)據(jù)欄的值相加
引用以上函數(shù)的方法:sql="selectsum(字段名)as別名from數(shù)據(jù)表where條件表達(dá)式"
setrs=conn.excute(sql)
用rs("別名")獲取統(tǒng)的計(jì)值,其它函數(shù)運(yùn)用同上。
數(shù)據(jù)表的建立和刪除:CREATETABLE數(shù)據(jù)表名稱(字段1類型1(長度),字段2類型2(長度)……)
例:CREATETABLEtab01(namevarchar(50),datetimedefaultnow())
DROPTABLE數(shù)據(jù)表名稱(永久性刪除一個(gè)數(shù)據(jù)表)
記錄集對(duì)象的方法:
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)前記錄,但記錄指針不會(huì)向下移動(dòng)
rs.addnew添加記錄到數(shù)據(jù)表末端
rs.update更新數(shù)據(jù)表記錄
判斷所填數(shù)據(jù)是數(shù)字型
ifnotisNumeric(request("字段名稱"))then
response.write"不是數(shù)字"
else
response.write"數(shù)字"
endif頁面執(zhí)行時(shí)間:
<%startime=Timer()%>
內(nèi)容
......
結(jié)尾
<%
DimEndtime
Endtime=Timer()
response.write"頁面執(zhí)行時(shí)間:<fontcolor=red>"&FormatNumber((Endtime-Startime)*1000,5)&"</font>毫秒"
%>定義打開網(wǎng)頁時(shí)起始窗口的大小
<scriptfor="window"event="onload">
window.resizeTo(500,300)
</script>
隨機(jī)數(shù):
<%randomize%>
<%=(int(rnd()*n)+1)%>
查詢數(shù)據(jù)時(shí)得到的記錄關(guān)鍵字用紅色顯示:
replace(RS("字段X"),searchname,"<fontcolor=#FF0000>"&searchname&"</font>")
通過asp的手段來檢查來訪者是否用了代理
<%ifRequest.ServerVariables("HTTP_X_FORWARDED_FOR")<>""then
response.write"<fontcolor=#FF0000>您通過了代理服務(wù)器,"&_
"真實(shí)的IP為"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")
endif
%>
判斷上一頁的來源
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("deletefromtablewhereidnotin(selectdistinctfromtable)")
文件刪除函數(shù)<%
'文件刪除函數(shù)
functiondeletefile(filename)
iffilename<>""then
setfso=server.CreateObject("scripting.filesystemobject")
iffso.FileExists(filename)then
fso.DeleteFilefilename
else
Response.Write"<script>alert(’該文件不存在’);</script>"
endif
endif
endfunction
strfile=server.MapPath("fileName")
deletefile(strfile)
%>
ASP字?jǐn)?shù)計(jì)算函數(shù)<%
FunctionWordCount(strInput)
DimstrTemp
strTemp=Replace(strInput,vbTab,"")
strTemp=Replace(strTemp,vbCr,"")
strTemp=Replace(strTemp,vbLf,"")
'刪除字首字尾空格
strTemp=Trim(strTemp)
'替換為一個(gè)空格
DoWhileInStr(1,strTemp,"",1)<>0
strTemp=Replace(strTemp,"","")
Loop
WordCount=UBound(Split(strTemp,"",-1,1))+1
EndFunction
%>全正則的檢測IP是否合法的函數(shù)
functioncheckIP2(sIPAddress)
{
varexp=/^(\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])$/;
varreg=sIPAddress.match(exp);
varErrMsg="你輸入的是一個(gè)非法的IP地址段!\nIP段為::xxx.xxx.xxx.xxx(xxx為0-255)!"
varMsg="你輸入的是一個(gè)合法的IP地址段!"
if(reg==null)
{
alert(ErrMsg);
}
else
{
alert(reg);
}
}
關(guān)閉子窗口時(shí)刷新父窗口在子窗口
<scriptlanguage="javascript">
window.opener.location="父窗口頁面"
window.close()
</script>
文本框輸入限制:
<script>functionregInput(obj,reg,inputStr){vardocSel=document.selection.createRange()if(docSel.parentElement().tagName!="INPUT")returnfalseoSel=docSel.duplicate()oSel.text=""varsrcRange=obj.createTextRange()oSel.setEndPoint("StartToStart",srcRange)varstr=oSel.text+inputStr+srcRange.text.substr(oSel.text.length)returnreg.test(str)}</script>小寫英文:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^[a-z]*$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^[a-z]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[a-z]*$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled"><br>大寫英文:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^[A-Z]*$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^[A-Z]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[A-Z]*$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled"><br>任意數(shù)字:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^[0-9]*$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^[0-9]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[0-9]*$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled"><br>限2位小數(shù):<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^\d*\.?\d{0,2}$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^\d*\.?\d{0,2}$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^\d*\.?\d{0,2}$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled">如:123.12<br>日期:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^\d{1,4}([-\/](\d{1,2}([-\/](\d{1,2})?)?)?)?$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled">如:2002-9-29<br>任意中文:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^[\u4E00-\u9FA5]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[\u4E00-\u9FA5]*$/,event.dataTransfer.getData('Text'))"><br>部分英文:<xmpstyle="display:inline"></xmp><inputonkeypress="returnregInput(this,/^[a-e]*$/,String.fromCharCode(event.keyCode))"onpaste="returnregInput(this,/^[a-e]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[a-e]*$/,event.dataTransfer.getData('Text'))"style="ime-mode:Disabled">范圍:a,b,c,d,e<br>部分中文:<xmpstyle="display:inline"></xmp><scriptlanguage=javascript>functioncheckChinese(oldLength,obj){varoTR=window.document.selection.createRange()varreg=/[^一二三四五六七八九十]/goTR.moveStart("character",-1*(obj.value.length-oldLength))oTR.text=oTR.text.replace(reg,"")}</script><inputonkeypress="returnfalse"onkeydown="setTimeout('checkChinese('+this.value.length+','+this.uniqueID+')',1)"onpaste="returnregInput(this,/^[一二三四五六七八九十]*$/,window.clipboardData.getData('Text'))"ondrop="returnregInput(this,/^[一二三四五六七八九十]*$/,event.dataTransfer.getData('Text'))">范圍:一二三四五六七八九十<br>
[Ctrl+A全選Ctrl+C復(fù)制]
不能點(diǎn)右鍵,不用CTRL+A,不能復(fù)制作!
<bodyoncontextmenu="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前
<baseonmouseover="window.status='這里是Goaler的Blog系統(tǒng),歡迎訪問';returntrue">
用鍵盤打開網(wǎng)頁<scriptlanguage=javascript>
document.onkeydown=gopage
varadd="Admin/AddArticle.asp"
varlogon="Admin/Logon.asp"
functiongopage(){
if(event.keyCode==13)location=add
if(event.keyCode==38)location=logon
}
</script>
根據(jù)內(nèi)容自動(dòng)調(diào)整iframe高度
有時(shí)為了方便使用Iframe,但被潛入的頁面長度不是固定的,顯示滾動(dòng)條不僅影響美觀還對(duì)用戶操作帶來不便,自動(dòng)調(diào)整高度可以解決這個(gè)問題。^_^
functionf_frameStyleResize(targObj)
{
vartargWin=targObj.parent.document.all[targO];
if(targWin!=null)
{
varHeightValue=targObj.document.body.scrollHeight
if(HeightValue<600){HeightValue=600}//不小于600
targWin.style.pixelHeight=HeightValue;
}
}
functionf_iframeResize()
{
bLoadComplete=true;
f_frameStyleResize(self);
}
varbLoadComplete=false;
window.onload=f_iframeResize;
禁止頁面正文內(nèi)容被選取
<bodyoncontextmenu="returnfalse"ondragstart="returnfalse"onselectstart="returnfalse"onselect="document.selection.empty()"oncopy="document.selection.empty()"onbeforecopy="return
false"onmouseup="document.selection.empty()">
消除ie6自動(dòng)出現(xiàn)的圖像工具欄,設(shè)置GALLERYIMG屬性為false或no.
<IMGSRC="mypicture.jpg"HEIGHT="100px"WIDTH="100px"GALLERYIMG="no">
防止點(diǎn)擊空鏈接時(shí),頁面往往重置到頁首端。
代碼“javascript:void(null)”代替原來的“#”標(biāo)記
如何避免別人把你的網(wǎng)頁放在框架中
<scriptlanguage=“javascript”><!--if(self!=top){top.location=self.location;}--></script>
頁面定時(shí)刷新
<metahttp-equiv="Refresh"content="秒">
頁面定時(shí)轉(zhuǎn)向新的地址
<metahttp-equiv="refresh"content="秒;URL=url">
關(guān)閉窗口,這個(gè)是不會(huì)彈出提示直接關(guān)的:
把如下代碼加入<body>區(qū)域中
<OBJECTid=closestype="application/x-oleobject"classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<paramname="Command"value="Close">
</object>
<scriptlanguage="JavaScript">functionshutwin(){closes.Click();return;}</script>
<ahref="javascript:shutwin();">關(guān)閉本窗口</a>
有時(shí)候好不容易寫出來的程序代碼被別人抄去,心里一定不好受。這還是小事,但如果在我們的源代碼中有一些不希望讓別人知道的內(nèi)容,比如密碼、Action的指向等,這些一旦被人利用,那后果有時(shí)是不堪設(shè)想的。而網(wǎng)頁加密就是我們現(xiàn)在需要解決的問題。下面就我在網(wǎng)頁制作中的一些經(jīng)驗(yàn)向大家介紹一些簡單的防范方法。
禁止右鍵
看到這里大家一定會(huì)想,這招有很多人介紹過了,而且破解的方法也有很多。但我這里要說的是另一種方法,而且我試了很多方法都沒有能破解。具體如下:
<html>
<head>
<script>
functionstop(){
alert("試試能破解嗎?");
returnfalse;
}
document.oncontextmenu=stop;
</script>
<boyd>你可以按右鍵、shift+F10和右ctrl左邊的那個(gè)鍵試試!看能不能解。^_^</body>
大家試試,看能不能破解!你可以將alert("試試能破解嗎?");這句去掉,這樣當(dāng)按右鍵時(shí)就什么反應(yīng)也沒有了,就好像沒有右鍵功能一樣。
禁示查看源代碼
我們已經(jīng)禁了右鍵,但從"查看"菜單下的"源文件"中同樣可以看到源代碼,下面我們就來解決這個(gè)問題:
其實(shí)這只要使用一個(gè)含有<frame></frame>標(biāo)記的網(wǎng)頁便可以達(dá)到目的。
<frameset>
<framesrc="你要保密的文件的URL">
</frameset>
這樣當(dāng)有人使用"查看"下的"源文件"的時(shí)候,看到的將是上面的那段代碼,而你真正的文件又躲過一劫。
禁示另存為
通過上面的兩步好像你的源代碼已經(jīng)安全了,但別忘了,別人還可以將你的頁面保存下來,再慢慢分析。不過別擔(dān)心,下面我們來解決這個(gè)問題。
在你要保密的網(wǎng)頁中加入以下代碼:
<noscript><iframesrc="*.htm"></iframe></noscript>
徹底屏蔽右鍵方法。
<bodyoncontextmenu="returnfalse">
雙擊頁面后自動(dòng)滾屏,單擊后停止。
<SCRIPTlanguage=JavaScript>
varcurrentpos,timer;
functioninitialize()
{timer=setInterval("scrollwindow()",16);}
functionsc(){
clearInterval(timer);
}
functionscrollwindow()
{currentpos=document.body.scrollTop;
window.scroll(0,++currentpos);
if(currentpos!=document.body.scrollTop)
sc();
}
document.onmousedown=sc
document.ondblclick=initialize
</script>
設(shè)定腳本出錯(cuò)能繼續(xù)運(yùn)行
<scriptlanguage="javascript">
functionKillError()
{
returnfalse;
}
window.oner
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 小麥加工資源增值策略考核試卷
- 土木工程建筑排水系統(tǒng)施工考核試卷
- 2017社保培訓(xùn)課件
- 孔樁勞務(wù)合同范本
- 民宅鋪面出售合同范本
- 碼頭設(shè)備采購合同范本
- 購買國外技術(shù)合同范本
- 熱水買賣合同范本
- led燈改造合同范本
- 寵物寄養(yǎng)服務(wù)中動(dòng)物健康保證協(xié)議
- 中國銀行中銀數(shù)字服務(wù)(南寧)有限公司招聘筆試真題2023
- 2024七年級(jí)英語下冊 Module 1 Lost and found教案(新版)外研版
- 2024年公共衛(wèi)生基本知識(shí)考試題庫(附含答案)
- 雞尾酒知識(shí)大全
- DL∕T 1432.1-2015 變電設(shè)備在線監(jiān)測裝置檢驗(yàn)規(guī)范 第1部分通 用檢驗(yàn)規(guī)范
- 上海的弄堂教案及教學(xué)說明 滬教版
- JTS-T-108-1-2019危險(xiǎn)貨物港口建設(shè)項(xiàng)目安全評(píng)價(jià)規(guī)范
- 如何正確運(yùn)用邏輯推理和論證方法撰寫文章
- 重慶西南大學(xué)附中2023-2024學(xué)年八年級(jí)下學(xué)期5月物理定時(shí)訓(xùn)練
- 保安公司新項(xiàng)目進(jìn)場方案(2篇)
- 《垃圾發(fā)電廠爐渣處理技術(shù)規(guī)范》
評(píng)論
0/150
提交評(píng)論