Large collection of classic ASP code

Source: Internet
Author: User
Tags servervariables classic asp server port

Oncontextmenu= "Window.event.returnvalue=false" will completely shield 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" no paste

4. oncopy= "return false;" oncut= "return false;" Prevent replication

5. <link rel= "shortcut icon" href= "Favicon.ico" > IE Address bar before switching to their own icon

6. <link rel= "bookmark" href= "Favicon.ico" > can display your icon in the Favorites folder

7. <input style= "ime-mode:disabled" > Close IME

8. Always with frame
<script language= "JavaScript" ><!--
if (window = = top) Top.location.href = "frames.htm"; Frames.htm for frames page
--></script>

9. Prevent people from being frame
<script language=javascript><!--
if (top.location! = self.location) top.location=self.location;
--></script>

<noscript><iframe src=*.html></iframe></noscript> Web page will not be saved as

<input type=button value= View Web page source code
onclick= "window.location = ' view-source: ' + ' http://www. Macaidong/'" >

12. How to check whether the visitor uses the agent by means of ASP
<% if Request.ServerVariables ("Http_x_forwarded_for") <> "then
Response.Write "<font color= #ff0000 > You passed the proxy server," & _
"Real 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 control position"
End Function
--></script>

14. The cursor is stopped at the end of text in the textbox
<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 ()" >

15. Determine the origin of the previous page
Asp:
Request.ServerVariables ("Http_referer")

Javascript:
Document.referrer

16. Minimize, maximize, close the window
<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= minimized onclick=hh1.click () >
<input Type=button value= Maximize Onclick=hh2.click () >
<input Type=button value= Close Onclick=hh3.click () >
This example applies to IE

17.
<%
' defines some constants for other database connections
Const ADOPENFORWARDONLY = 0 ' cursor only browses the record forward, does not support paging, Recordset, bookmark
Const ADOPENKEYSET = 1 ' keyset cursor, changes that other users make to the record will be reflected in the recordset, but other users adding or deleting records will not be reflected in the recordset. Support for paging, Recordset, bookmark
The const ADOPENDYNAMIC = 2 ' dynamic cursor is the strongest, but the most expensive source. Changes that the user makes to the record, add or delete records are reflected in the recordset. Full-featured browsing is supported (access is not supported).
The const adOpenStatic = 3 ' static cursor is just a snapshot of the data, and the user modifies the record, adding or deleting records that are not reflected in the recordset. Supports moving forward or backward

Const ADLOCKREADONLY = 1 ' lock type, default, read-only, cannot be modified
Const adLockPessimistic = 2 ' The safest way to lock records immediately when editing
Const adLockOptimistic = 3 ' The recordset is locked only when the Update method is called, while other operations in the previous operation can still make changes, insertions, and deletions to the current record
Const adLockBatchOptimistic = 4 ' records are not locked when editing, and changes, insertions, 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, 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, Jul 1997 05:00:00 GMT");
Header ("Cache-control:no-cache, must-revalidate");
Header ("Pragma:no-cache");

19. Check to see if a string is all made up 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 determine if it is a character
if (/[^\x00-\xff]/g.test (s)) alert ("contains Chinese characters");
else alert ("All characters");

22.textarea Adaptive number of lines of text
<textarea Rows=1 name=s1 cols=27 onpropertychange= "This.style.posheight=this.scrollheight" >
</textarea>

23. Date minus number of 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 are selected
function Checkme ()
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" onclick= "Checkme ()" >
</body>

25. Get the Request.ServerVariables ("") collection of the URL of 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 Time <%=server.scripttimeout%>
This file path <%=server.mappath (Request.ServerVariables ("Script_name"))%>
Number of server CPUs <%=request.servervariables ("Number_of_processors")%>
Server Interpreter engine <%=scriptengine & "/" & ScriptEngineMajorVersion & "." &scriptengineminorversion& "." & ScriptEngineBuildVersion%>
Server operating system <%=request.servervariables ("OS")%>

27.enter key to move the cursor to the next input box
<input onkeydown= "if (event.keycode==13) event.keycode=9" >

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 Cursor
Wait: Waiting cursor
Text:i-shaped cursor
Vertical-text: Horizontal I-shaped cursor
No-drop: Cannot drag cursor
Not-allowed: Invalid cursor
Help:? Aid cursor
All-scroll: Triangle Direction mark
Move: Moving the label
Crosshair: Cross-label
E-resize
N-resize
Nw-resize
W-resize
S-resize
Se-resize
Sw-resize

Large collection of classic ASP code

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.