Este artigo descreve o método de vibrar o efeito especial do mouse JS deslizando sobre a imagem. Compartilhe para sua referência. O método de implementação específico é o seguinte:
Copie o código da seguinte forma: <html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = gb2312">
<title> deslize o mouse sobre o efeito de vibração da imagem </title>
<Estilo> .ShakeImage {
Posição: relativa
}
</Style>
</head>
<Body>
<Idioma do script = javascript1.2>
<!-
var refletor = 3
var stopit = 0
var a = 1
função init (que) {
Stopit = 0
shake = qual
shake.style.left = 0
shake.style.top = 0
}
função rattleImage () {
if ((! document.all &&!
Retornar
if (a == 1) {
shake.style.top = parseint (shake.style.top)+reitor
}
else if (a == 2) {
shake.style.left = parseint (shake.style.left)+reitor
}
else if (a == 3) {
shake.style.top = parseint (shake.style.top) -rector
}
outro{
shake.style.left = parseint (shake.style.left) -rector
}
se (a <4)
a ++
outro
a = 1
setTimeout ("rattleImage ()", 50)
}
função stoprattle (que) {
Stopit = 1
qual.style.left = 0
qual.style.top = 0
}
//->
</Script>
<img onmouseover = "init (this); rattleImage ()" onmouseout = "stoprattle (this)" src = "/imagens/csrcode.ico" style = "cursor: pointer;"/>
<img onmouseover = "init (this); rattleImage ()" onmouseout = "stoprattle (this)" src = "/imagens/changshi.ico" style = "cursor: pointer;"/>
<img onmouseover = "init (this); rattleImage ()" onmouseout = "stoprattle (this)" src = "/imaga/links.ico" style = "cursor: pointer;"/>
Deslize o mouse sobre o efeito de visualização da imagem.
</body>
</html>
Espero que este artigo seja útil para a programação JavaScript de todos.