Javascript summary commonly used in B and S mode projects

  • 2020-03-30 00:54:37
  • OfStack

Right click of screen cheat page
< Body oncontextmenu = "return false" > Or < Body style = "overflow - y: hidden" >

Add background music to the page
IE: < Bgsound SRC = "*. Mid" loop = infinite>
NS: < Embed SRC ="*. Mid "autostart=true hidden=true loop=true> < / embed>
*. Mid MIDI format file for your background music

Automatically opens and closes Windows

< Script Language = "& # 106 avascript" >
The function winopen1 () {
Open window name =open("nb","Homepage","toolbar=no,location=no,
Directories = no, status = no, menubar = no, scrollbars = no, the resizable = no.
Copyhistory = no, width = 160, height = 200, left = 200, top = 100 "; )
< / script>

< A href  OnMouseOver = "winopen1 (); Return true;" OnMouseOut =" the name of the window that opens. Close ();" >
< P> Here's the connection < / a> < / p>

Causes the browser to fail while saving the page, preventing the user from saving the screen
< NOSCRIPT> < Iframe SRC = ". * HTML "> < / iframe> < / NOSCRIPT>

Web page closes automatically
< Html>
< Head>
< The object id = closes type = "application/x - oleobject"
Every "that adb880a6 - cf d8ff - 11-9377-00 aa003b7a11" >
< Param name = "Command" value = "Close" >
< / object>
< / head>
< The body onload = "window. SetTimeout (' closes. Click ()", 10000) ">
The window will close automatically after 10 seconds and there will be no prompt.
< / body>
< / html>

More tips:

1. Oncontextmenu ="window.event.return value=false" will completely block the right mouse button
< The table border oncontextmenu = return (false) > < Td> No< / table> Can be used in the Table

2. < Body onselectstart = "return false" > Unselect and prevent replication

Onpaste ="return false"

4. Oncopy = "return false;" Oncut = "return false;" To prevent copying

5. < Link rel = "Shortcut Icon" href = "favicon. Ico" > Replace the IE address bar with your own icon

6. < Link rel = "Bookmark" href = "favicon. Ico" > Can show your icon in the favorites

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

8. Always carry the frame
< Script language = "javascript" > < ! --
If (window == top)top. Location. Href = "frames. HTM "; File ://frames. HTM is the frame web page
/ / - > < / script>

9. Prevent frames
< SCRIPT LANGUAGE = javascript> < ! --
If (top location! = self. Top location). The location = self. The location;
/ / - > < / SCRIPT>

10. < Noscript> < Iframe SRC = *. Html> < / iframe> < / noscript> Web pages will not be saved as

11. < Input type=button value= view page source code
Onclick = "window location = 'view - source:' + '/ / www.jb51.net/" >

The cursor is at the end of the text box
< Script language = "javascript" >
The function of cc ()
{
Var e = event. SrcElement;
Var r = e.c. with our fabrication: reateTextRange ();
R.m oveStart (' character, e.v alue. Length);
R.c ollapse (true);
R.s well ();
}
< / script>
< Input type=text name=text1 value="123" onfocus="cc()">

15. Determine the source of the previous page
Asp:
Request. Servervariables (" HTTP_REFERER ")
Javascript:
Document. The referrer

Minimize, maximize, and close Windows
< Object id = hh1 every "that ADB880A6 - cf D8FF - 11-9377-00 aa003b7a11" >
< Param name = "Command" value = "Minimize" > < / object>
< Object id = hh2 every "that ADB880A6 - cf D8FF - 11-9377-00 aa003b7a11" >
< Param name = "Command" value = "Maximize" > < / object>
< OBJECT id = hh3 every "that adb880a6 - cf d8ff - 11-9377-00 aa003b7a11" >
< 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= close onclick= hh3.click ()>
This example applies to IE

Pages will not be cached
HTM page
< META HTTP - EQUIV = "pragma" CONTENT = "no - cache" >
< META HTTP - EQUIV = "cache-control" CONTENT = "no - Cache, and must - revalidate" >
< META httpe-equiv ="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
Or < META HTTP - EQUIV = "expires" CONTENT = "0" >

Check if a string is made up entirely of Numbers
< Script language = "javascript" > < ! --
The function checkNum (STR) {return STR. Match (\ D /) = = null}
Alert (checkNum (" 1232142141 "))
Alert (checkNum (" 123214214 a1 "))
/ / - > < / script>

21. How do I tell if it's a character
If (/[^\x00-\ XFF]/g.test(s)) alert(" contains Chinese characters ");
Else alert(" all characters ");

22. The number of TEXTAREA adaptive text lines
< Textarea rows=1 name=s1 cols=27 onpropertychange=" this.style.posheight = this.scrollheight ">
< / textarea>

The date minus the days equals the second date
< Script language = javascript>
The function of cc (dd, dadd)
{
Var a = new Date(dd)
A = Dr. AlueOf ()
A = a - dadd * 24 * 60 * 60 * 1000
A = new Date (a)
Alert (al-qeada etFullYear () + "years" + (al-qeada etMonth () + 1) + "month" + al-qeada etDate () + ", ")
}
Cc (" 12/23/2002 ", 2)
< / script>

27. The ENTER key moves the cursor to the next input field
< Input onkeydown = "if (event. KeyCode = = 13) event. The keyCode = 9" >


Related articles: