This article mainly introduces the classic code of IE operations in JavaScript. If you need some help, please refer to it and hope to help you with ajax technology, therefore, we have more opportunities to learn JavaScript knowledge. I have previously collected some JavaScript code on the Internet for IE operations (I can't remember where the idea is, so I won't add the source). It feels useful in the development process, of course, this only applies to IE and FF. Post it for sharing.
The Code is as follows:
1. the right mouse button will be completely shielded
Oncontextmenu = "window. event. returnvalue = false"
Available for Table
2. Cancel selection and prevent Replication
3. Do not paste
Onpaste = "returnfalse"
4. Prevent Replication
Oncopy = "returnfalse ;"
Oncut = "returnfalse ;"
5. Replace the IE icon in front of the address bar
6. You can display your icons in the favorites folder.
7. Disable the Input Method
8. Always carry the framework
Script
9. Prevent frame
SCRIPT
10. The webpage cannot be saved
11. view the webpage source code
12. How to use asp to check whether the visitor has used an agent?
<% IfRequest. ServerVariables ("HTTP_X_FORWARDED_FOR") <> "then
Response. write "you have passed the proxy server ,"&_
"The real IP address is" & Request. ServerVariables ("HTTP_X_FORWARDED_FOR ")
Endif
%>
13. Obtain the absolute position of the control
// Javascript
FunctiongetIE (e )...{
Vart = e. offsetTop;
Varl = e. offsetLeft;
While (e = e. offsetParent )...{
T + = e. offsetTop;
L + = e. offsetLeft;
}
Alert ("top =" + t + "left =" + l );
}
Script
// VBScript
Script
14. The cursor stops at the end of the text box.
Functioncc ()
...{
Vare = event. srcElement;
Varr = e. createTextRange ();
R. moveStart ('character ', e. value. length );
R. collapse (true );
R. select ();
}
Script
15. determine the source of the previous page
Asp:
Request. servervariables ("HTTP_REFERER ")
Javascript:
Document. referrer
16. Minimize, maximize, and close the window
This example applies to IE
17.
<%
'Define some constants for database connection
ConstadOpenForwardOnly = 0' the cursor only views records forward, and does not support paging, Recordset, and BookMark.
ConstadOpenKeyset = 1' indicates the keyset cursor. modifications made by other users to the record are reflected in the record set. However, adding or deleting records by other users is not reflected in the record set. Supports paging, Recordset, and BookMark
ConstadOpenDynamic = 2' the most dynamic cursor function, but the most resource consumption. The added or deleted records modified by the user on the record description will be reflected in the record set. Supports full-featured browsing (ACCESS is not supported ).
ConstadOpenStatic = 3' the static cursor is only a snapshot of the data. The changes you make to the record description will not be reflected in the record set. Supports moving forward or backward
ConstadLockReadOnly = 1' lock type, default, read-only, cannot be modified
ConstadLockPessimistic = 2' lock the record immediately when editing, the safest way
ConstadLockOptimistic = 3' the record set is locked only when the Update method is called, and other operations before this can still change, insert, and delete the current record.
ConstadLockBatchOptimistic = 4' records are not locked when being edited, but changes, inserts, and deletes are completed in the batch processing mode.
Constad1_text = & H0001
ConstadCmdTable = & H0002
%>
18. The webpage will not be cached
HTM webpage
Or
ASP Web Page
Response. Expires =-1
Response. ExpiresAbsolute = Now ()-1
Response. cachecontrol = "no-cache"
PHP webpage
Header ("Expires: Mon, 26Jul199705: 00: 00GMT ");
Header ("Cache-Control: no-cache, must-revalidate ");
Header ("Pragma: no-cache ");
19. check whether a string is composed of digits.
Script
20. Get the size of a window
Document. body. clientWidth, document. body. clientHeight
21. How can I determine whether it is a character?
If (/[^-then]/g. test (s) alert ("containing Chinese characters ");
Elsealert ("All characters ");
22. Number of lines of TEXTAREA adaptive text
23. The date minus the number of days equals to the second date
Functioncc (dd, dadd)
{
// Add error handling.
Vara = newDate (dd)
A = a. valueOf ()
A = a-dadd * 24x60*60*1000
A = newDate ()
Alert (a. getFullYear () + "year" + (a. getMonth () + 1) + "month" + a. getDate () + "day ")
}
Cc ("12/23/2002", 2)
Script
24. Which Radio is selected
Functioncheckme ()
Foreachobinradio1
Ifob. checkedthenwindow. alertob. value
Next
Endfunction
Script
Style
Barcode
25. Obtain the request. servervariables ("") set of the url on this page.
Response. Write" Variables Value"
ForeachobinRequest. ServerVariables
Response. Write""& Ob &""& Request. ServerVariables (ob )&""
Next
Response. Write""
26.
Local ip address <% = 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 %>
Path of this file <% = server. mappath (Request. ServerVariables ("SCRIPT_NAME") %>
Server CPU count <% = Request. ServerVariables ("NUMBER_OF_PROCESSORS") %>
Server interpretation engine <% = ScriptEngine & "/" & ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion & "." & ScriptEngineBuildVersion %>
Server Operating System <% = Request. ServerVariables ("OS") %>
27. Press ENTER to move the cursor to the next input box.
28. Check the link speed of a Website:
Add the following codeRegion:
Tim = 1
SetInterval ("tim + +", 100)
B = 1
Varautourl = newArray ()
Autourl [1] = "<src =" pic/url.gif "align = absMiddle border = 0> www.njcatv.net"
Autourl [2] = "javacool.3322.net"
Autourl [3] = "<src =" pic/url.gif "align = absMiddle border = 0> www.sina.com.cn"
Autourl [4] = "www.nuaa.edu.cn"
Autourl [5] = "<src =" pic/url.gif "align = absMiddle border = 0> www.cctv.com"
Functionbutt (){
Document. write ("")
}
Butt ()
Functionauto (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 + "second "}
B ++
}
Functionrun () {for (vari = 1; ihttp: // "; + autourl [I] +" ')> ")}
Run () script
29. Various styles of cursor
Auto: Standard cursor
Default: Standard arrow
Hand: hand-shaped cursor
Wait: waiting for the cursor
Text: I-shaped cursor
Vertical-text: horizontal I-shaped cursor
No-drop: Do not drag the cursor
Not-allowed: Invalid cursor
Help :? Help cursor
All-scroll: triangle direction indicator
Move: move mark
Crosshair: Cross logo
E-resize
N-resize
Nw-resize
W-resize
S-resize
Se-resize
Sw-resize
1. There is no local cache, and each time it is automatically refreshed
Response. expires = 0
Response. addHeader "pragma", "no-cache"
Response. addHeader "cache-control", "private"
2. Modify contentType and download gif and other formats
<%
Functiondl (f, n)
Onerrorresumenext
Sets = CreateObject ("Adodb. Stream ")
S. Mode = 3
S. Type = 1
S. Open
S. LoadFromFile (server. mappath (f ))
Iferr. number> 0 then
Response. writeerr. number & ":" & err. description
Else
Response. contentType = "application/x-gzip"
Response. addheader "Content-Disposition:", "attachment; filename =" & n
Response. binarywrite (s. Read (s. size ))
Endif
Endfunction
Calldl ("012922501.gif"," t1.gif ")
%>
19. check whether a string is composed of digits.
Script
20. Get the size of a window
Document. body. clientWidth, document. body. clientHeight
Document. body. offsetWidth, document. body. offsetHeight
Sometimes you need to know window. screenTop, window. screenLeft
21. How to determine whether Chinese characters are contained
If (escape (str). indexOf ("% u ")! =-1) alert ("containing Chinese characters ");
Elsealert ("All characters ");
22. Number of lines of TEXTAREA adaptive text
IE5.5 + can use overflow-y: visible
23. The date minus the number of days equals to the second date
Function cc (dd, dadd)
...{
// Add error handling.
Vard = newDate (dd. replace ("-","/"))
D. setDate (d. getDate () + dadd)
Alert (d. getFullYear () + "year" + (d. getMonth () + 1) + "month" + d. getDate () + "day ")
}
Cc ("2002-2-28", 2)
Script