Some ASP code worth collecting some ASP code
1. oncontextmenu= "Window.event.returnvalue=false" will completely screen the right mouse button
<table border Oncontextmenu=return (false) ><td>no</table> available for table
2. <body onselectstart= "return false" > deselect, prevent copying
3. onpaste= "return false" is not allowed to paste
4. oncopy= ' return false; ' oncut= ' return false; ' Prevent replication
5. <link rel= "shortcut icon" href= "Favicon.ico" > IE Address bar before replacing their own icons
6. <link rel= "Bookmark" href= "Favicon.ico" > can display your icon in a Favorites folder
7. <input style= "ime-mode:disabled" > Close IME
8. Always with the frame
<script language= "JavaScript" ><!--
if (window = top) Top.location.href = "frames.htm"; Frames.htm for frames page
--></script>
9. Prevent a person from being frame
<script language=javascript><!--
if (top.location!= self.location) top.location=self.location;
--></script>
<noscript><iframe src=*.html></iframe></noscript> Web pages will not be saved as
<input type=button value= View Web page source code
>
12. How to use the ASP means to check whether the visitor used the agent
<% if Request.ServerVariables ("Http_x_forwarded_for") <> "" Then
Response.Write "<font color= #FF0000 > You have passed the proxy server," & _
"True IP is" &request.servervariables ("Http_x_forwarded_for")
End If
%>
13. Get the absolute position of the control
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 & "left=" &l,64, "get position of control"
End Function
--></script>
14. Cursor is stopped at the end of text box text
<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" >
15. Determining the origin of the previous page
Asp:
Request.ServerVariables ("Http_referer")
Javascript:
Document.referrer
16. Minimize, maximize, close windows
<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= Minimize onclick=hh1. Click () > <input Type=button value= maximize ONCLICK=HH2. Click () > <input type=button value= closes Onclick=hh3. Click () > This example applies to IE
17.
<%
' Define some constants for database connections
The Const adopenforwardonly = 0 ' cursor only browses the record forward, does not support paging, Recordset, BookMark
The Const adOpenKeyset = 1 ' keyset cursor, the changes that other users make to the record are reflected in the recordset, but additional users adding or deleting records are not reflected in the recordset. Support paging, Recordset, BookMark
The Const adopendynamic = 2 ' Dynamic cursors are the most powerful, but also the most expensive sources. User changes to the record, add or delete records will be reflected in the recordset. Supports full feature browsing (not supported by Access).
Const adopenstatic = 3 ' static cursors, just a snapshot of the data, changes that the user makes to the record, adding or deleting records are not reflected in the recordset. Supports moving forward or backward
Const adlockreadonly = 1 ' lock type, default, read-only, cannot make any changes
Const adlockpessimistic = 2 ' When editing immediately locks records, the safest way
Const adlockoptimistic = 3 ' The recordset is locked only when the Update method is called, while other previous operations can still make changes, inserts, and deletes to the current record.
Const adlockbatchoptimistic = 4 ' records are not locked while editing, and changes, inserts, and deletions are done in batch mode
Const adCmdText = &h0001
Const adCmdTable = &h0002
%>
18. Web pages are not cached
HTM Web page
<meta http-equiv= "Pragma" content= "No-cache" > <meta http-equiv= "Cache-control" content= "No-cache", Must-revalidate "> <meta http-equiv=" Expires "content=" Wed, Feb 1997 08:21:57 GMT "> or <meta http-equiv=" Expires "content=" 0 "> ASP Web page
Response.Expires =-1
Response.ExpiresAbsolute = Now ()-1
Response.CacheControl = "No-cache"
PHP Web page
Header ("Expires:mon, June June 1997 05:00:00 GMT");
Header ("Cache-control:no-cache, must-revalidate");
Header ("Pragma:no-cache");
19. Check whether a string of strings is all composed of numbers
<script language= "JavaScript" ><!--
function Checknum (str) {return Str.match (/\d/) ==null}
Alert (Checknum ("1232142141"))
Alert (Checknum ("123214214A1"))
--></script>
20. Get the size of a window
Document.body.clientwidth,document.body.clientheight
21. How to judge whether it is a character
if (/[^\x00-\xff]/g.test (s)) alert ("contains Chinese characters");
else alert ("All characters");
22.TEXTAREA the number of adaptive lines of text
<textarea Rows=1 name=s1 cols=27 onpropertychange= "This.style.posheight=this.scrollheight" > </textarea>
23. Date minus days equals second date
<script language=javascript> function cc (DD,DADD)
{//Can add error handling
var a = new Date (DD)
A = A.valueof ()
A = A-dadd * 24 * 60 * 60 * 1000
A = new Date (a)
Alert (a.getfullyear () + "year" + (A.getmonth () + 1) + "month" + a.getdate () + "Day")
CC ("12/23/2002", 2)
</script>
24. Which radio was chosen
For each OB in Radio1
If ob.checked then Window.alert ob.value
Next
End Function
</script><BODY> <input name= "Radio1" type= "Radio" value= "style" Checked>style
<input name= "Radio1" type= "Radio" value= "barcode" >barcode
<input type= "button" value= "Check" > </BODY></HTML>
25. Get the Request.ServerVariables ("") collection of the URL on this page
Response.Write "<table border=1><!--TABLE Header--><tr><td><b>variables</b> </TD><TD><B>value</B></TD></TR> "
For each OB in Request.ServerVariables
Response.Write "<TR><TD>" &ob& "</TD><TD>" &request.servervariables (OB) & " </TD></TR> "
Next
Response.Write "</TABLE>"
26.
Native Ip<%=request.servervariables ("REMOTE_ADDR")%> server name <%=request.servervariables ("SERVER_NAME")%> Server Ip<%=request.servervariables ("LOCAL_ADDR")%> Server Port <%=request.servervariables ("SERVER_PORT")%> Server Time <%=now%> IIS version <%=request.servervariables "Server_software")%> script timeout <%=server.scripttimeout% > This file path <%=server.mappath (Request.ServerVariables ("Script_name")%> Server CPU number <%= Request.ServerVariables ("number_of_processors")%> Server Interpreter engine <%=scriptengine & "/" & ScriptEngineMajorVersion & "." &ScriptEngineMinorVersion& "." & scriptenginebuildversion%> Server operating system <%=request.servervariables ("OS")%>
The 27.ENTER key allows the cursor to move to the next input box
<input >
28. Detect the link speed of a website:
Add the following code to the <body> area:
<script language=javascript> Tim=1
SetInterval ("tim++", 100)
B=1
var autourl=new Array ()
autourl[1]= "Www.njcatv.net"
autourl[2]= "Javacool.3322.net"
autourl[3]= "www.sina.com.cn"
autourl[4]= "www.nuaa.edu.cn"
autourl[5]= "Www.cctv.com"
function Butt () {
document.write ("<form name=autof>")
for (Var i=1;i<autourl.length;i++)
document.write ("<input type=text name=txt" +i+ "size=10 value= Test ......> =" <input type=text name=url "+i+" size=40 > = "<input type=button value=go onclick=window.open (this.form.url" +i+ ". Value) ><br/>")
document.write ("<input type=submit value= Refresh ></form>")
} Butt ()
function Auto (URL) {
document.forms[0]["url" +b].value=url
if (tim>200)
{document.forms[0]["txt" +b].value= "link Timeout"}
Else
{document.forms[0]["txt" +b].value= "time" +tim/10+ "Seconds"}
b++
function run () {for (Var i=1;i<autourl.length;i++) document.write ("Run () </script>
29. Various styles of cursors
Auto: Standard cursor
Default: Standard arrow
Hand: hand-shaped cursor
Wait: Waiting for cursor
Text:i-shaped cursor
Vertical-text: Horizontal i-type cursor
No-drop: Non-drag cursor
Not-allowed: Invalid cursor
Help:? Helper cursors
All-scroll: Triangle directional Sign
Move: Moving the label
Crosshair: Cross Mark
E-resize
N-resize
Nw-resize
W-resize
S-resize
Se-resize
Sw-resize
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.