Javascript技巧大集合文档格式.docx
《Javascript技巧大集合文档格式.docx》由会员分享,可在线阅读,更多相关《Javascript技巧大集合文档格式.docx(55页珍藏版)》请在冰豆网上搜索。
3.鼠标移入移出时颜色变化
submit"
找吧"
name="
B1"
onMouseOut=this.style.color="
blue"
onMouseOver=this.style.color="
red"
class="
button"
4.平面按钮
inputtype=submitvalue=订阅style="
border:
1pxsolid:
#666666;
height:
17px;
width:
25pt;
font-size:
9pt;
BACKGROUND-COLOR:
#E8E8FF;
color:
#666666"
[color=#ffffff][/color]
5.按钮颜色变化
inputtype=textname="
nick"
style="
1pxsolid#666666;
#F4F4FF;
#ff6600"
size="
15"
maxlength="
16"
6.平面输入框
T1"
20"
border-style:
solid;
border-width:
1"
7.使窗口变成指定的大小
script>
window.resizeTo(300,283);
/script>
8.使文字上下滚动
marqueedirection=upscrollamount=1scrolldelay=100onmouseover='
this.stop()'
onmouseout='
this.start()'
height=60>
!
--head_scrolltext-->
tr>
td>
共和国
/table>
<
!
--endhead_scrolltext-->
/marquee>
9.状态栏显示该页状态
base>
10.可以点击文字实现radio选项的选定
br>
&
nbsp;
nbsp;
radio"
regtype"
A03"
id="
labelfor="
情侣:
一次注册两个帐户<
/label>
11.可以在文字域的font写onclick事件
12.打印<
/a>
打印网页
ahref=()'
13.线型输入框
key"
12"
关键字"
onFocus=this.select()onMouseOver=this.focus()
class="
line"
14.显示文档最后修改日期
scriptlanguage=javascript>
functionhi(str)
{
document.write(document.lastModified)
alert("
hi"
+str+"
"
)
}
15.可以在鼠标移到文字上时就触发事件
html>
head>
scriptlanguage="
LiveScript"
--Hiding
functionhello(){
哈罗!
);
/head>
body>
ahref=
/body>
/html>
16.可以根据网页上的选项来确定页面颜色
HTML>
HEAD>
TITLE>
background.html<
/TITLE>
/HEAD>
SCRIPT>
--
functionbgChange(selObj){
newColor=selObj.options[selObj.selectedIndex].text;
document.bgColor=newColor;
selObj.selectedIndex=-1;
//-->
/SCRIPT>
BODYSTYLE="
font-family:
Arial"
B>
ChangingBackgroundColors<
/B>
BR>
FORM>
SELECTSIZE="
8"
OPTION>
Red
Orange
Yellow
Green
Blue
Indigo
Violet
White
pink
/SELECT>
/FORM>
/BODY>
/HTML>
17.将按钮的特征改变
styletype="
text/css"
.style1{font-size:
12px;
background:
#CCCCFF;
thinthinthinthin;
border-color:
#CCCCFF
#CCCCCC#CCCCCC#CCCCFF}
.style2{font-size:
font-weight:
bold;
#CCFFCC;
thinmediummediumthin;
border-color:
#CCFF99#999999#999999#CCFF99}
-->
/style>
本例按钮的代码如下:
Submit"
提交"
onmouseout="
this.className='
style1'
style1"
18.改变按钮的图片.
.style3{font-size:
url(image/buttonbg1.gif);
border:
0px;
60px;
22px}
.style4{font-size:
url(image/buttonbg2.gif);
0px0;
60px;
本例的按钮代码如下:
Submit2"
style3'
style3"
19.打印页面
divalign="
center"
aclass=contenthref="
javascript:
doPrint();
打印本稿<
/div>
20.可以直接写html语言
document.write("
21.改变下拉框的颜色
selectname="
classid"
onChange="
changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)"
size="
1"
color:
#008080;
font-size:
9pt"
22.转至目标URL
window.location="
http:
//guoguo"
23.传递该object的form
UpdateSN('
guoqiang99267'
this.form)
functionUpdateSN(strValue,strForm)
strForm.SignInName.value=strValue;
returnfalse;
24.文字标签
labelfor="
AltName4"
inputname="
AltName"
type="
RADIO"
tabindex="
931"
guoqiang99859<
25.layer2为组件的ID,可以控制组件是否可见
document.all.item('
Layer2'
).style.display="
block"
;
none"
//
26.将页面加入favorite中
functionAddme(){
url="
//your.site.address"
//你自己的主页地址
title="
YourSiteName"
//你自己的主页名称
window.external.AddFavorite(url,title);
27.过10秒自动关闭页面
JavaScript"
>
functioncloseit(){
setTimeout("
self.close()"
,10000)
/script>
28.可以比较字符的大小
char=post.charAt(i);
if(!
('
0'
=char&
char<
='
9'
))
29.将字符转化为数字
month=parseInt(char)
30.点击value非空的选项时转向指定连接
selectonchange='
if(this.value!
="
)window.open(this.value)'
textinput"
optionselected>
主办单位<
/option>
option>
-----------------<
optionvalue=