一直用document,今天偶尔知道了一些用法,小小总结一下:
<script>
/**
* 修改文档颜色
*/
function changeColor() {
// fgColor指字体颜色
document.fgColor = "red";
// bgColor指背景色
document.bgColor = "white";
// vlinkColor指用户已访问过的链接颜色
document.vlinkColor = "orange";
}
function getButton() {
// 判断是否IE浏览器,只有IE支持all[]
if(document.all){
var genders = document.all["gender"];
for(i=0; i<genders.length; i++) {
// 直接用 if(genders[i].checked) { 亦可
if(genders[i].checked == true) {
alert("您选择的是:"+genders[i].value);
}
}
}
}
</script>
<body author="maxEric" date="2007-03-01">
<input type=text value=haha>haha<a href="#">1213143</a>
<input type=radio name=gender value=male>男<input type=radio name=gender value=female>女
<input type=button name=btn value=变颜色 onClick=changeColor() onBlur=getButton()>
</body>