Dengan mengubah gaya tampilan tombol, swiping tombol dinamis tercapai
Salinan kode adalah sebagai berikut:
<! Doctype html public "-// w3c // dtd xhtml 1.0 transisi // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "konten tipe" content = "text /html; charset = utf-8" />
<title> unt judul dokumen </iteme>
</head>
<tyle>
.search {latar belakang:#008800; Warna: #fff; Perbatasan: Tidak Ada; Tinggi: 26px; Line-Height: 20px; Lebar: 63x;}
.searchhover {latar belakang:#000099; Warna: #fff; Perbatasan: Tidak Ada; Tinggi: 26px; Line-Height: 20px; Lebar: 63px; }
</tyle>
</head>
<body onload = "js ()">
<input type = "tombol" id = "btn" name = "btn" value = "login"/>
<input type = "tombol" id = "btn2" name = "btn" value = "logout"/>
<type skrip = "Teks/JavaScript">
fungsi js ()
{
// Buat tombol dukungan IE6 Atribut Hover OBJ, entitas yang ingin mendukung Hover adalah gaya BTN: Hover, dan init adalah gaya awal
obj = "btn";
peringatan (navigator.appname);
if (navigator.appname == "microsoft internet explorer" && parsefloat (navigator.appversion) == 4) {// penilaian IE6
var o = document.getElementsbyname (obj);
untuk (var i = 0; i <o.length; i ++) {
if (o [i] .type == "tombol") {
//oILMiace.className = "cari";
o [i] .onmouseOver = function () {this.className = "SearchHover"}
o [i] .onmouseout = function () {this.className = "cari"};
}
}
}
}
</script>
</body>
</html>