熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

站長必收藏的一些ASP代碼

2022-06-13   來源: .NET編程 

  ASP代碼值得收藏的一些ASP代碼
oncontextmenu="windoweventreturnvalue=false" 將徹底屏蔽鼠標右鍵
<table border oncontextmenu=return(false)><td>no</table> 可用於Table
<body onselectstart="return false"> 取消選取防止復制
onpaste="return false" 不准粘貼
oncopy="return false;" oncut="return false;" 防止復制
<link rel="Shortcut Icon" href="faviconico"> IE地址欄前換成自己的圖標
<link rel="Bookmark" href="faviconico"> 可以在收藏夾中顯示出你的圖標
<input style="imemode:disabled"> 關閉輸入法
永遠都會帶著框架
<script language="javascript"><!
if (window == top)toplocationhref = "frameshtm"; //frameshtm為框架網頁
// ></script>
防止被人frame
<SCRIPT LANGUAGE=javascript><!
if (toplocation != selflocation)toplocation=selflocation;
// ></SCRIPT>
<noscript><iframe src=*html></iframe></noscript> 網頁將不能被另存為
<input type=button value=查看網頁源代碼
onclick="windowlocation = viewsource:+ ;">
怎樣通過asp的手段來檢查來訪者是否用了代理
<% if RequestServerVariables("HTTP_X_FORWARDED_FOR")<>"" then
responsewrite "<font color=#FF>您通過了代理服務器"& _
"真實的IP為"&RequestServerVariables("HTTP_X_FORWARDED_FOR")
end if
%>
取得控件的絕對位置
//javascript
<script language="javascript"> function getIE(e){
var t=eoffsetTop;
var l=eoffsetLeft;
while(e=eoffsetParent){
t+=eoffsetTop;
l+=eoffsetLeft;
} alert("top="+t+"nleft="+l);
} </script>
//VBScript
<script language="VBScript"><!
function getIE()
dim tlab
set a=documentallimg
t=documentallimgoffsetTop
l=documentallimgoffsetLeft
while atagName<>"BODY"
set a = aoffsetParent
t=t+aoffsetTop
l=l+aoffsetLeft
wend
msgbox "top="&t&chr()&"left="&l"得到控件的位置"
end function
></script>
光標是停在文本框文字的最後
<script language="javascript"> function cc()
{ var e = eventsrcElement;
var r =ecreateTextRange();
rmoveStart(characterevaluelength);
rcollapse(true);
rselect();
} </script> <input type=text name=text value="" onfocus="cc()">
判斷上一頁的來源
asp:
requestservervariables("HTTP_REFERER")
javascript:
documentreferrer
最小化最大化關閉窗口
<object id=hh classid="clsid:ADBADFFCFAABA">
<param name="Command" value="Minimize"></object> <object id=hh classid="clsid:ADBADFFCFAABA">
<param name="Command" value="Maximize"></object> <OBJECT id=hh classid="clsid:adbadffcfaaba"> <PARAM NAME="Command" value="Close"></OBJECT>
<input type=button value=最小化 onclick=hhClick()> <input type=button value=最大化 onclick=hhClick()> <input type=button value=關閉 onclick=hhClick()> 本例適用於IE

<%
定義數據庫連接的一些常量
Const adOpenForwardOnly = 游標只向前浏覽記錄不支持分頁RecordsetBookMark
Const adOpenKeyset = 鍵集游標其他用戶對記錄說做的修改將反映到記錄集中但其他用戶增加或刪除記錄不會反映到記錄集中支持分頁RecordsetBookMark
Const adOpenDynamic = 動態游標功能最強但耗資源也最多用戶對記錄說做的修改增加或刪除記錄都將反映到記錄集中支持全功能浏覽(ACCESS不支持)
Const adOpenStatic = 靜態游標只是數據的一個快照用戶對記錄說做的修改增加或刪除記錄都不會反映到記錄集中支持向前或向後移動
Const adLockReadOnly = 鎖定類型默認的只讀不能作任何修改
Const adLockPessimistic = 當編輯時立即鎖定記錄最安全的方式
Const adLockOptimistic = 只有在調用Update方法時才鎖定記錄集而在此前的其他操作仍可對當前記錄進行更改插入和刪除等
Const adLockBatchOptimistic = 當編輯時記錄不會被鎖定而更改插入和刪除是在批處理方式下完成的
Const adCmdText = &H
Const adCmdTable = &H
%>
網頁不會被緩存
HTM網頁
<META HTTPEQUIV="pragma" CONTENT="nocache"> <META HTTPEQUIV="CacheControl" CONTENT="nocache mustrevalidate"> <META HTTPEQUIV="expires" CONTENT="Wed Feb :: GMT"> 或者<META HTTPEQUIV="expires" CONTENT=""> ASP網頁
ResponseExpires =
ResponseExpiresAbsolute = Now()
Responsecachecontrol = "nocache"
PHP網頁
header("Expires: Mon Jul :: GMT");
header("CacheControl: nocache mustrevalidate");
header("Pragma: nocache");
檢查一段字符串是否全由數字組成
<script language="javascript"><!
function checkNum(str){return strmatch(/D/)==null}
alert(checkNum(""))
alert(checkNum("a"))
// ></script>
獲得一個窗口的大小
documentbodyclientWidthdocumentbodyclientHeight
怎麼判斷是否是字符
if (/[^xxff]/gtest(s)) alert("含有漢字");
else alert("全是字符");
TEXTAREA自適應文字行數的多少
<textarea rows= name=s cols= onpropertychange="thisstyleposHeight=thisscrollHeight"> </textarea>
日期減去天數等於第二個日期
<script language=javascript> function cc(dddadd)
{ //可以加上錯誤處理
var a = new Date(dd)
a = avalueOf()
a = a dadd * * * *
a = new Date(a)
alert(agetFullYear() + "年" + (agetMonth() + ) + "月" + agetDate() + "日")
} cc("//")
</script>
選擇了哪一個Radio
<HTML><script language="vbscript"> function checkme()
for each ob in radio
if obchecked then windowalert obvalue
next
end function
</script><BODY> <INPUT name="radio" type="radio" value="style" checked>Style
<INPUT name="radio" type="radio" value="barcode">Barcode
<INPUT type="button" value="check" onclick="checkme()"> </BODY></HTML>
獲得本頁url的requestservervariables("")集合
ResponseWrite "<TABLE border=><! Table Header ><TR><TD><B>Variables</B></TD><TD><B>value</B></TD></TR>"
for each ob in RequestServerVariables
ResponseWrite "<TR><TD>"&ob&"</TD><TD>"&RequestServerVariables(ob)&"</TD></TR>"
next
ResponseWrite "</TABLE>"

本機ip<%=requestservervariables("remote_addr")%> 服務器名<%=RequestServerVariables("SERVER_NAME")%> 服務器IP<%=RequestServerVariables("LOCAL_ADDR")%> 服務器端口<%=RequestServerVariables("SERVER_PORT")%> 服務器時間<%=now%> IIS版本<%=RequestServerVariables"SERVER_SOFTWARE")%> 腳本超時時間<%=ServerScriptTimeout%> 本文件路徑<%=servermappath(RequestServerVariables("SCRIPT_NAME"))%> 服務器CPU數量<%=RequestServerVariables("NUMBER_OF_PROCESSORS")%> 服務器解譯引擎<%=ScriptEngine & "/"& ScriptEngineMajorVersion &""&ScriptEngineMinorVersion&""& ScriptEngineBuildVersion %> 服務器操作系統<%=RequestServerVariables("OS")%>
ENTER鍵可以讓光標移到下一個輸入框
<input onkeydown="if(eventkeyCode==)eventkeyCode=">
檢測某個網站的鏈接速度
把如下代碼加入<body>區域中:
<script language=javascript> tim=
setInterval("tim++")
b=
var autourl=new Array()
autourl[]="wwwjjjnet"
autourl[]="sjjsnet"
autourl[]="wwwjajjjcn"
autourl[]="wwwssscn"
autourl[]="wwwjjcom"
function butt(){
documentwrite("<form name=autof>")
for(var i=;i<autourllength;i++)
documentwrite("<input type=text name=txt"+i+" size= value=測試中……> =》<input type=text name=url"+i+" size=> =》<input type=button value=GO onclick=windowopen(thisformurl"+i+"value)><br/>")
documentwrite("<input type=submit value=刷新></form>")
} butt()
function auto(url){
documentforms[]["url"+b]value=url
if(tim>)
{documentforms[]["txt"+b]value="鏈接超時"}
else
{documentforms[]["txt"+b]value="時間"+tim/+"秒"}
b++
} function run(){for(var i=;i<autourllength;i++)documentwrite("<img src=http://"+autourl+"/"+Mathrandom()+" width= height= onerror=auto(http://";;+autourl+")>")}
run()</script>
各種樣式的光標
auto 標准光標
default 標准箭頭
hand 手形光標
wait 等待光標
text I形光標
verticaltext 水平I形光標
nodrop 不可拖動光標
notallowed 無效光標
help ?幫助光標
allscroll 三角方向標
move 移動標
crosshair 十字標
eresize
nresize
nwresize
wresize
sresize
seresize
swresize
 


From:http://tw.wingwit.com/Article/program/net/201311/14222.html
    相關文章
      没有相关文章
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.