Common JavaScript code (3): javascript code
The article is from "PHP100 Chinese network"
8. Make the text scroll up or 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. the status bar shows the status of this page.
<Base onmouseover = "window. status = 'website construction http://www.webmake.cn/'; return true">
10. You can click the text to select the radio option.
<Br>
<Input type = "radio" name = "regtype" value = "A03" id = "A03">
<Label for = "A03"> couples: register two accounts at a time </label> <br>
11. onclick events can be written in the font of the text field.
12. Print </a> the web page
<A href = 'javascript: window. print () '>
13. Line type input box
<Input type = "text" name = "key" size = "12" value = "keyword" onFocus = this. select () onMouseOver = this. focus ()
Class = "line">
14. display the last modification date of the document
<Script language = javascript>
Function hi (str)
{
Document. write (document. lastModified)
Alert ("hi" + str + "! ")
}
</Script>
15. An event can be triggered when you move the cursor over the 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 Colors </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 features of the button
<Style type = "text/CSS">
<! --
. Style1 {font-size: 12px; background: # CCCCFF; border-width: thin; border-color: # CCCCFF
# CCCCCC # CCCCFF}
. Style2 {font-size: 12px; font-weight: bold; background: # CCFFCC; border-width: thin medium thin;
Border-color: # CCFF99 #999999 #999999 # CCFF99}
-->
</Style>
The code for the buttons in this example is as follows:
<Input type = "submit" name = "Submit" value = "submit" onmouseover = "this. className = 'style2 '"
Onmouseout = "this. className = 'style1'" class = "style1">