Common JS Code in ASP. NET

Source: Internet
Author: User
JS commonly used in ASP. NET Code
Dialog Box

1. A prompt box is displayed.

Alert ("prompt box, haha ");

2. A confirmation box is displayed.

Return confirm ("confirmation box, haha ");

IV. Other common JS

1. oncontextmenu = "window. event. returnvalue = false" will completely block the right mouse button

<Table border oncontextmenu = return (false)> <TD> NO </table>

2. <body onselectstart = "Return false"> cancel selection to prevent Replication

3. onpaste = "Return false" Do not paste

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. You can display your icons in the favorites folder.

7. Disable the Input Method

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

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

10. The webpage cannot be saved

11. <input type = button value = view web pageSource codeOnclick = "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> after you pass the proxy server," & _ "the real IP address is" & request. servervariables ("http_x_forwarded_for") end if %>

13. Obtain 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 (13) & "Left =" & L, 64, "Get control position"

End function -->

</SCRIPT>

14. 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 ()">

15. determine the source of the previous page

ASP: request. servervariables ("http_referer ")

Java Script: Document. referrer

16. Minimize, maximize, and 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 = maximized onclick = hh2.click ()> <input type = button value = Disable onclick = hh3.click ()> This example applies to IE

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.