Construction Station teaching Network collection of more than 100 commonly used JS code

Source: Internet
Author: User
Keywords Web page production Ajax javascript
Tags ajax button change class code color change document file

1. Text box Focus problem
OnBlur: This event occurs when the input focus is lost
OnFocus: When the input gets focus, the file is generated
Onchange: This event occurs when the literal value changes
Onselect: When the text is highlighted, the file is generated
<input type= "text" value= "Qiang" onfocus= "if (value== ' Qiang ') {value= '}" onblur= "if
(value== ') {value= ' qiang '} ' > Text disappears when clicked, and text appears when you lose focus

2. The special color of the Web button
<input Type=button name= "Submit1" value= Qiang "size=10" Class=s02
Style= "Background-color:rgb (235,207,22)" >
3. Color change when mouse is moved
<input type= "Submit" value= "Find It" name= "B1" onmouseout=this.style.color= "Blue"
Onmouseover=this.style.color= "Red" class= "button" >
4. Flat button
<input type=submit value= Subscription style= "border:1px Solid: #666666; height:17px; width:25pt; font-size:9pt;
Background-color: #E8E8FF; Color: #666666 "Name=" >


5. Button color change
<input type=text name= "Nick" style= border:1px solid #666666; font-size:9pt; height:17px;
Background-color: #F4F4FF; Color: #ff6600 "size=" maxlength= ">"


6. Flat input Box
<input type= "text" name= "T1" size= "style=" border-style:solid; Border-width:1 ">


7. Change the window to a specified size
<script>
Window.resizeto (300,283);
</script>
8. Make text scroll up and down
<marquee direction=up scrollamount=1 scrolldelay=100 onmouseover= ' this.stop () ' onmouseout= ' This.start () '


Height=60>
<!--Head_scrolltext-->
<tr>
<td>
Republic
</table> <!--end Head_scrolltext-->
</marquee>


9. Status bar shows the page status
<base onmouseover= "window.status= ' website construction http://www.admin5.cn/'; return true" >
10. You can click on the text to implement the selection of radio option
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<input type= "Radio" name= "Regtype" value= "A03" id= "A03" >
<label for= "A03" > Couple: Register two accounts at a time </label> <br>
11. You can write the onclick event in a text field
12. Print </a> Print web pages
<a href= ' javascript:window.print () ' >
13. Line Type input Box
<input type= "text" name= "key" size= "value=" keyword Onfocus=this.select () onmouseover=this.focus ()


class= "line" >
14. Display document last Modified date
<script language=javascript>
function Hi (str)
{
document.write (document.lastmodified)


 alert ("HI" +str+ "!")
}
</script>
15. You can trigger an event when you move the mouse over text
<html>
<head>
<script language= LiveScript
<!--hiding
    function hello () {
      alert ( "Hello!");
   }
</script>
</head>
<body>
<a href= "onmouseover=" Hello () >link</a>
</body>
</html>
16. You can determine the page color based on the options on the page
<html>
<head>
 <title >background.html</title>
</head>
<script>
<!--


Function Bgchange (selobj) {
 newcolor = Selobj.options[selobj.selectedindex].text;
  Document.bgcolor = Newcolor;
 selobj.selectedindex =-1;
 }
//-->
</script>
<body style= "font-family:arial"
<b>changing Background </b>
<br>
 <form>
 <select size= "8 onchange=" bgchange (this);
 <option>red
 <option>orange
 <option>yellow
 < Option>green
 <option>blue
 <option>indigo
 <option>violet
 <option>white
 <option>pink
 </select>
 </form>
</ Body>
</HTML>
17. Change the feature of the button
<style type= "Text/css"
<!--
. style1 {font-size:12px; Background: #CCCCFF; Border-width:thin thin thin thin; Border-color: #CCCCFF
#CCCCCC #CCCCCC #CCCCFF}
. style2 {font-size:12pX; Font-weight:bold; Background: #CCFFCC; Border-width:thin medium medium thin;


Border-color: #CCFF99 #999999 #999999 #CCFF99}

Related Article

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.