تصف هذه المقالة طريقة اهتزاز التأثير الخاص لضرب الماوس JS على الصورة. شاركه للرجوع إليه. طريقة التنفيذ المحددة هي كما يلي:
انسخ الرمز كما يلي: <html>
<head>
<meta http-equiv = "content-type" content = "text/html ؛ charset = gb2312">
<title> انقلب الماوس فوق تأثير اهتزاز الصورة </title>
<style> .shakeimage {
الموقف: قريب
}
</style>
</head>
<body>
<لغة البرنامج النصي = javaScript1.2>
<!-
var Reflector = 3
var stopit = 0
var a = 1
وظيفة init (التي) {
StopIt = 0
هز =
Shake.style.left = 0
Shake.style.top = 0
}
وظيفة RattleImage () {
if ((! document.all &&! document.getElementById) || stopit == 1)
يعود
if (a == 1) {
Shake.style.top = parseint (Shake.style.top)+Rector
}
آخر إذا (a == 2) {
Shake.style.left = parseint (Shake.style.left)+Rector
}
آخر إذا (a == 3) {
Shake.style.top = parseint (Shake.Style.top)-المحامي
}
آخر{
Shake.style.left = parseint (Shake.Style.Left) -erctor
}
إذا (A <4)
A ++
آخر
أ = 1
setTimeout ("RattleImage ()" ، 50)
}
وظيفة stoprattle (التي) {
StopIt = 1
الذي
الذي. style.top = 0
}
//->
</script>
<img onMouseover = "init (this) ؛ rattleimage ()" onMouseout = "stopRattle (this)" src = "/csrcode.ico style =" cursor: pointer ؛ "/>
<img onMouseover = "init (this) ؛ rattleimage ()" onMouseout = "stopRattle (this)" src = "/changshi.ico" style = "cursor: pointer ؛"/>
<img onMouseover = "init (this) ؛ rattleimage ()" onMouseout = "stopRattle (this)" src = "/links.ico" style = "cursor: pointer ؛"/>
حرك الماوس فوق تأثير معاينة الصورة.
</body>
</html>
آمل أن تكون هذه المقالة مفيدة لبرمجة JavaScript للجميع.