js鼠標(biāo)滑過圖片震動(dòng)特效的方法
更新時(shí)間:2015年02月17日 12:04:10 作者:代碼家園
這篇文章主要介紹了js鼠標(biāo)滑過圖片震動(dòng)特效的方法,涉及onMouseOver事件及圖片操作的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了js鼠標(biāo)滑過圖片震動(dòng)特效的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>鼠標(biāo)滑過 圖片震動(dòng)效果</title>
<STYLE>.shakeimage {
POSITION: relative
}
</STYLE>
</head>
<body>
<SCRIPT language=JavaScript1.2>
<!--
var rector=3
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
//-->
</SCRIPT>
<img class="shakeimage" onMouseOver="init(this);rattleimage()" onMouseOut="stoprattle(this)" src="/images/csrcode.ico" border="0" style="cursor:pointer;"/>
<img class="shakeimage" onmouseover="init(this);rattleimage()" onmouseout="stoprattle(this)" src="/images/changshi.ico" border="0" style="cursor:pointer;"/>
<img class="shakeimage" onmouseover="init(this);rattleimage()" onmouseout="stoprattle(this)" src="/images/links.ico" border="0" style="cursor:pointer;"/>
鼠標(biāo)滑過圖片預(yù)覽效果。
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>鼠標(biāo)滑過 圖片震動(dòng)效果</title>
<STYLE>.shakeimage {
POSITION: relative
}
</STYLE>
</head>
<body>
<SCRIPT language=JavaScript1.2>
<!--
var rector=3
var stopit=0
var a=1
function init(which){
stopit=0
shake=which
shake.style.left=0
shake.style.top=0
}
function rattleimage(){
if ((!document.all&&!document.getElementById)||stopit==1)
return
if (a==1){
shake.style.top=parseInt(shake.style.top)+rector
}
else if (a==2){
shake.style.left=parseInt(shake.style.left)+rector
}
else if (a==3){
shake.style.top=parseInt(shake.style.top)-rector
}
else{
shake.style.left=parseInt(shake.style.left)-rector
}
if (a<4)
a++
else
a=1
setTimeout("rattleimage()",50)
}
function stoprattle(which){
stopit=1
which.style.left=0
which.style.top=0
}
//-->
</SCRIPT>
<img class="shakeimage" onMouseOver="init(this);rattleimage()" onMouseOut="stoprattle(this)" src="/images/csrcode.ico" border="0" style="cursor:pointer;"/>
<img class="shakeimage" onmouseover="init(this);rattleimage()" onmouseout="stoprattle(this)" src="/images/changshi.ico" border="0" style="cursor:pointer;"/>
<img class="shakeimage" onmouseover="init(this);rattleimage()" onmouseout="stoprattle(this)" src="/images/links.ico" border="0" style="cursor:pointer;"/>
鼠標(biāo)滑過圖片預(yù)覽效果。
</body>
</html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- jsp圖片效果大全(圖像震動(dòng)效果、閃爍效果、自動(dòng)切換圖像)
- javascript實(shí)現(xiàn)手機(jī)震動(dòng)API代碼
- js 鼠標(biāo)放圖片上抖動(dòng)效果
- javascript實(shí)現(xiàn)的仿騰訊QQ窗口抖動(dòng)效果代碼
- js 窗口抖動(dòng)示例
- js模擬QQ窗口的抖動(dòng)效果
- js實(shí)現(xiàn)鼠標(biāo)觸發(fā)圖片抖動(dòng)效果的方法
- JS實(shí)現(xiàn)仿QQ聊天窗口抖動(dòng)特效
- jquery.messager.js插件導(dǎo)致頁面抖動(dòng)的解決方法
- js窗口震動(dòng)小程序分享
相關(guān)文章
JS多個(gè)矩形塊選擇效果代碼(模擬CS結(jié)構(gòu))
非常不錯(cuò)的可以選擇多個(gè)矩形塊的功能代碼2008-11-11
Electron無邊框自定義窗口拖動(dòng)的問題小結(jié)
最近使用了electron框架,發(fā)現(xiàn)如果自定義拖動(dòng)是比較實(shí)用的;特別是定制化比較高的項(xiàng)目,如果單純的使用-webkit-app-region:?drag;會(huì)讓鼠標(biāo)事件無法觸發(fā),這篇文章主要介紹了Electron無邊框自定義窗口拖動(dòng)的問題小結(jié),需要的朋友可以參考下2024-04-04
詳解webpack引入第三方庫的方式以及注意事項(xiàng)
這篇文章主要介紹了詳解webpack引入第三方庫的方式以及注意事項(xiàng),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2019-01-01
file模式訪問網(wǎng)頁時(shí)iframe高度自適應(yīng)解決方案
最近做到iframe的高度自適應(yīng)這個(gè)問題;發(fā)現(xiàn)自己做的網(wǎng)頁是通過file方式訪問的,將網(wǎng)頁代碼放到apache下通過http協(xié)議訪問,在iframe加載的時(shí)候調(diào)用如下js方法:果然網(wǎng)頁高度能夠自適應(yīng)(對(duì)于其他方案應(yīng)該也有效果,我沒有注意去嘗試)感興趣的朋友可以了解下2013-01-01
一個(gè)JavaScript用逗號(hào)分割字符串實(shí)例
分割字符串的方法有很多,這篇文章主要介紹了一個(gè)JavaScript用逗號(hào)分割字符串實(shí)例,需要的朋友可以參考下2014-09-09

