Right-click shielding
<A href = "http://ywicc.com" onmousedown = "If (event. Button = 2) Alert ('offset')"> ywicc.com </a>
Web Screen Saver
<Script language = "JavaScript">
Function screensave (){
Test. Value ++;
If (test. value = 5 ){
Test. style. Display = 'none ';
Document. All [4]. bgcolor = 'black ';
}
}
Function screenopen (){
Test. value = 0;
Test. style. Display = '';
Document. All [4]. bgcolor = '';
}
</SCRIPT>
<Body onkeydown = "screenopen ()" onmousemove = "screenopen ()" onLoad = "setinterval ('screensave () ', 1000)">
5-second screen saver <input id = "test">
Defines the size of the Start window when a Web page is opened.
<Script for = "window" event = "onLoad">
Window. resizeTo (500,300)
</SCRIPT>
Regular Expressions for letters and numbers
<Input onkeyup = "this. value = This. value. replace (/[^ A-Za-Z \ D]/g, '')" onbeforepaste = "this. value = This. value. replace (/[^ A-Za-Z \ D]/g, '')">
Layer that does not scroll with the page
<Body onscroll = "d1.style. Top = Document. Body. scrolltop + 10">
<Div id = "d1" style = "position: absolute; top: 10px; width: 100px; Height: 100px; Background-color: red;"> </div>
The same button in a form submits two pages
<Script language = "JavaScript">
Function testform (){
Window. Open ('', 't1 ');
Form1.action='1.htm ';
Form1.target = 't1 ';
Form1.submit ();
Window. Open ('', 't2 ');
Form1.action='2.htm ';
Form1.target = 't2 ';
Form1.submit ();
Window. Open ('', 't3 ');
Form1.action='3.htm ';
Form1.target = 't3 ';
Form1.submit ();
}
</SCRIPT>
<Form name = "form1">
<Input name = "test">
<Input type = "button" value = "Submit" onclick = "testform ()">
</Form>
Determine if it is a number<Input type = "text" name = "num"> <input type = "button" name = "test" onclick = "testnum ()">
<Script language = "JavaScript">
<! --
Function testnum (){
VaR pattern =/^ \ D + $/g;
If (! (Pattern. Test (Num. Value )))
{Alert ("Please input a number! ")}
}
// -->
</SCRIPT>
ALT and title branches<A href = "#" Title = "Change
Row and line "> test </a>
Cancel selection and prevent Replication
<Body onselectstart = "Return false">
<P> 111111111111111111111111111111111 </P>
</Body>
Disable Input Method
<Input style = "ime-mode: Disabled">
Always carry the framework
<Script language = "JavaScript"> <! --
If (window = Top) top. Location. href = "frames.htm"; // frames.htm is the frame webpage.
// --> </SCRIPT>
Prevent Frame
<Script language = JavaScript> <! --
If (top. location! = Self. Location) top. Location = self. location;
// --> </SCRIPT>
Webpages cannot be saved
<NoScript> <IFRAME src = *. html> </iframe> </NoScript>
Confirm deletion
<A href = 'javascript: If (confirm ("are you sure you want to delete it? ") Location =" boos. asp? & Areyou = Delete & page = 1 "'> Delete </a>
Obtain the absolute position of a widget
// 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>
The cursor stops at the end of the text box.
<Script language = "JavaScript">
Function CC ()
Mask function keys shift, ALT, CTRL
<SCRIPT>
Function look (){
If (event. shiftkey)
Alert ("do not press shift! "); // You can change it to alt CTRL
}
Document. onkeydown = look;
</SCRIPT>
The webpage will not be cached
<Meta HTTP-EQUIV = "Pragma" content = "no-Cache">
<Meta HTTP-EQUIV = "cache-control" content = "no-cache, must-revalidate">
<Meta HTTP-EQUIV = "expires" content = "wed, 26 Feb 1997 08:21:57 GMT">
Or <meta HTTP-EQUIV = "expires" content = "0">
How to make the form feel free
<Input type = text style = "border: 1 solid #000000">
Or
<Input type = text style = "border-left: none; border-Right: none; border-top: none; border-bottom: 1 solid #000000"> </textarea>
<Div> <span> & <layer> Differences<Div> (Division) is used to define the page elements of a large segment, and a line is generated.
<Span> is used to define elements in the same row. The only difference between <div> and <div> is that no transpose is generated.
<Layer> is the NS tag, which is not supported by IE, which is equivalent to <div>
Make the pop-up window always at the top
<Body onblur = "This. Focus ();">
Do not scroll bar
Make the vertical bar not:
<Body style = 'overflow: Scroll; overflow-Y: Den den '>
</Body>
Make the horizontal bar unavailable:
<Body style = 'overflow: Scroll; overflow-X: Den den '>
</Body>
Remove both of them? Simpler
<Body scroll = "no">
</Body>
How to remove the image link and click the dotted line around the image
<A href = "#" onfocus = "This. Blur ()"> </a>
Email processing submission form <form name = "form1" method = "Post" Action = "mailt ***** @ ***. com" enctype = "text/plain">
<Input type = submit>
</Form>
Child Window refresh parent window. opener. Location. Reload ()
How to add a background image that is not full? The background image does not move when pulling the page <style>
Body
{Background-image: URL (images/51js/51js.gif); background-repeat: No-Repeat; Background-position: center; Background-Attachment: Fixed}
</Style>
Check whether a string is composed of digits <script language = "JavaScript"> <! --
Function checknum (STR) {return Str. Match (// D/) = NULL}
Alert (checknum ("1232142141 "))
Alert (checknum ("123214214a1 "))
// --> </SCRIPT>
Restrict the selected width from the drop-down list.<Select name = "select" style = "width: 300"> </SELECT>
Open a new window, and the width and height of the window is the actual height and width of the image
Center the pop-up window
Method 1:
<SCRIPT>
Mywin = Window. Open ("about: blank", "", "width = 200, Height = 160 ");
Mywin. moveTo (screen. width/2-100, screen. Height/2-80 );
</SCRIPT>Method 2:
<SCRIPT>
T = 200;
L = 200;
Window. open ('about: blank ', '', 'width =' + L + ', Height =' + T + ', Top =' + (screen. availheight/2-T/2) + ', Left =' + (screen. availwidth/2-l/2 ));
</SCRIPT>