Dieser Artikel beschreibt die Methode zur Schwingung des Spezialeffekts der JS -Maus, die über das Bild wischt. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <html>
<kopf>
<meta http-äquiv = "content-type" content = "text/html; charset = gb2312">
<titels> Wischen Sie die Maus über den Bildschwingungseffekt </title>
<Styles> .shakeiMage {
Position: Relativ
}
</Style>
</head>
<body>
<Script Language = JavaScript1.2>
<!-
var reflektor = 3
var stopit = 0
var a = 1
Funktion init (was) {
stopit = 0
Shake = welches
Shake.Style.Left = 0
Shake.Style.top = 0
}
Funktion rassimage () {
if ((! document.all &&! document.getElementById) || stopit == 1)
Zurückkehren
if (a == 1) {
Shake.Style.top = ParseInt (Shake.Style.top)+Rektor
}
sonst wenn (a == 2) {
Shake.Style.Left = ParseInt (Shake.Style.Left)+Rektor
}
sonst wenn (a == 3) {
Shake.Style.top = ParseInt (Shake.Style.top) -Rector
}
anders{
Shake.Style.Left = ParseInt (Shake.Style.Left) -Rector
}
if (a <4)
A ++
anders
a = 1
setTimeout ("RattleImage ()", 50)
}
Funktion stoprattle (welche) {
Stopit = 1
welche.style.left = 0
welche.style.top = 0
}
//->
</Script>
<img onmouseover = "init (this); rassleImage ()" onmouseout = "stopRattle (this)" src = "/bilder/csrcode.ico" style = "cursor: pointer;"/>
<img onmouseover = "init (this); rastleImage ()" onmouseout = "stopRattle (this)" src = "/bils/changshi.ico" style = "cursor: pointer;"/>
<img onmouseover = "init (this); rastleImage ()" onmouseout = "stopRattle (this)" src = "/images/links.ico" style = "cursor: pointer;"/>
Schieben Sie die Maus über den Bildvorschau -Effekt.
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.