Common JavaScript code in Web pages

Source: Internet
Author: User

1. prohibit right-clicking, selecting, copying, and pasting
<Body oncontextmenu = "Return false" ondragstart = "Return false" onselectstart = "Return false" onselect = "document. selection. empty () "oncopy =" document. selection. empty () "onbeforecopy =" Return false "onmouseup =" document. selection. empty ()>

2. Do not right-click oncontextmenu = "Return false"

3. Disable onpaste = "Return false"

4. oncopy = "Return false;" oncut = "Return false;" Prevent Replication

5. <LINK rel = "shortcut icon" href = "favicon. ICO"> replace it with your own icon in front of the IE Address Bar

6. <LINK rel = "bookmark" href = "favicon. ICO"> your Icons can be displayed in favorites.

7. <input style = "ime-mode: Disabled"> disable the input method.

8. Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </SCRIPT>

9. Prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>

10. <NoScript> <IFRAME src = *. html> </iframe> </NoScript> webpages cannot be saved

11. <input type = button value = view web pageSource code
Onclick = "window. Location = 'view-Source: '+ 'HTTP: // www.csdn.net/'">

12. How to use ASP to check whether the visitor has used an agent?
<% If request. servervariables ("http_x_forwarded_for") <> "then
Response. Write "<font color = # ff0000> you have passed the proxy server ,"&_
"The real IP address is" & request. servervariables ("http_x_forwarded_for ")
End if
%>

13. The cursor stops at the end of the text box.
<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 ()">

14. determine the source of the previous page
ASP:
Request. servervariables ("http_referer ")

Javascript:
Document. referrer

20. Get the size of a window
Document. Body. clientwidth, document. Body. clientheight

21. How can I determine whether it is a character?
If (/[^ \ x00-\ xFF]/g. test (s) Alert ("containing Chinese characters ");
Else alert ("All characters ");

22. Number of lines of textarea adaptive text
<Textarea rows = 1 name = S1 Cols = 27 onpropertychange = "This. style. posheight = This. scrollheight">
</Textarea>

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.
<Input onkeydown = "If (event. keycode = 13) event. keycode = 9">

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

------------------------------------- Return the key value of the key in JS ------------------------------
<SCRIPT event = "onkeydown" for = "document">
Alert (event. keycode)
</SCRIPT>

---------------------------------------------------------------------







all options:

-------------------- Call and paste the 37 2007-10-5 board --------------------------
<Script language = "JavaScript">
Function copyurl (){
VaR CSTR = "";
CSTR + = "the most eccentric car collection in the world ";
CSTR + = "\ r \ http://auto.qq.com/a/20071004/000027.htm ";
Window. clipboardData. setdata ("text", CSTR );
Alert ('Press Ctrl + V and paste it on QQ to your friends! ');
}
</SCRIPT>

 

------------------- Set the text font size ---------------------------------------------------
<Script language = "JavaScript">
Function T (n ){
Document. getelementbyid ("articlecnt"). style. fontsize = N + "PX ";
}
</SCRIPT>

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.