導航:首頁 > 編程語言 > js滑鼠閃閃

js滑鼠閃閃

發布時間:2023-03-13 07:48:45

js滑鼠移入移出後元素會出現一直閃動,怎麼回事

//移入
function starMove()
{
var doc = document;
var oBox = doc.getElementById("box");
var timer = null;

clearInterval(timer);
timer = setInterval(function()
{
var speed = 10;

if(oBox.offsetLeft >= 0)
{
clearInterval(timer);
}
else
{
oBox.style.left = oBox.offsetLeft + speed + 'px';
}
}, 30)
}
//移出
function starMove2()
{
var doc = document;
var oBox = doc.getElementById("box");
var timer = null;

clearInterval(timer);
timer = setInterval(function()
{
var speed = 10;

if(oBox.offsetLeft == -150)
{
clearInterval(timer);
}
else
{
oBox.style.left = oBox.offsetLeft - speed + 'px';
}
}, 30)
}

這倆個方法里的time的定義位置問題,,,,你把time變成全局變數就沒問題了

每次執行的時候都是新的time變數,,,所以停止不了前面的定時器。

❷ js控制的圖片切換總是閃爍(滑鼠還未離開切換區,只要輕輕碰一下滑鼠,顯示的大圖來回閃,高手幫幫忙)

因為滑鼠進去的時候,觸發了onmouseover事件,執行ShowImage函數,圖片的display變成了none,圖片就隱藏了,這版個時候滑鼠就無法繼續在圖權片上,也就立刻就離開了圖片,因此執行了onmouseout事件,又是ShowImage函數,將圖片的display屬性變成了空,圖片又回來了,此時又觸發了onmouseover事件,於是悲劇了,死循環了。。。

❸ JS控制滑鼠點擊的代碼

這樣是不可以的!來 如果可以隨便控源制別人的滑鼠
那外掛不是滿天飛了啊
你只能獲得 滑鼠的 值
event.x 滑鼠的橫坐標 event.y 滑鼠的縱坐標
enevt 必須 寫在 時間的調用方法裡面
不可以直接 使用
只有 在事件的調用中才存在event 對象

不可以 但是 你可以控制項的 onclick 事件
<input type=button id=dd value="ddd" onclick="alert('11111')">
<script for = window event=onload>
document.all.dd.onclick();
//頁面載入的時候就自動點擊這個按鈕
</script>

❹ js 自定義的cursor在滑鼠移動的時候不斷閃爍,可行必追加50

<bodybgColor=#000>
<SCRIPTlanguage=javaScript>
<!--
//!!
colours=newArray('ff0000','00ff00','3366ff','ff00ff','ffa500','ffffff','fff000')

//Alternothingbelow!!
amount=colours.length;
YgetDelay=0,XgetDelay=0,Ydelay=0,Xdelay=0,ns=(document.layers)?1:0,step=0.2,currStep=0,my=0,mx=0;
if(ns){
for(i=0;i<amount;i++)
document.write('<LAYERNAME="nsstars'+i+'"BGCOLOR='+colours[i]+'CLIP="0,0,2,2"></LAYER>');
}
else{
document.write('<divid="ie"style="position:absolute;top:0;left:0;"><divstyle="position:relative">');
for(i=0;i<amount;i++)
document.write('<spanid="iestars"style="position:absolute;top:0;left:0;width:2px;height:2px;background:'+colours[i]+';font-size:2px"></span>');
document.write('</div></div>');
}
if(ns){
window.captureEvents(Event.MOUSEMOVE);
functionnMouse(evnt){
my=evnt.pageY;mx=evnt.pageX
}
window.onMouseMove=nMouse;
}
else{
functioniMouse(){
my=event.y;mx=event.x;
}
document.onmousemove=iMouse
}
functionstars(){
if(!ns)ie.style.top=document.body.scrollTop;
for(i=0;i<amount;i++)
{
varlayer=(document.layers)?document.layers["nsstars"+i]:iestars[i].style;
layer.top=Ydelay+100*Math.sin((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10);
layer.left=Xdelay+180*Math.cos((5*Math.sin((currStep-15.99)/10))+i*70)*Math.sin((currStep)/10)*Math.cos((currStep+i*25)/10);
}
currStep+=step;
}

functiondelay(){
Ydelay=YgetDelay+=(my-YgetDelay)*1/20;
Xdelay=XgetDelay+=(mx-XgetDelay)*1/20;
stars();
setTimeout('delay()',10);
}
delay();
//-->
</SCRIPT>
</body>

復制,保存*.html就行

❺ js製作滑鼠移動到圖片上的動畫

//html
onmouseover=mouseOver()換成onmouseover=mouseOver(this)
onmouseout=mouseOut()換成onmouseout=mouseOut(this)
//js更改透明度即可,不需要換圖片
functionmouseOver(obj){
obj.style.opacity=0.5;
}
functionmouseOut(obj){
obj.style.opacity=1;
}

❻ 如何用JS寫滑鼠觸發事件

簡單的示例div的背景色會隨著滑鼠進入變紅離開變白點擊變綠雙擊變藍版

vardivs=document.getElementsById('div1');
divs.onmouseover=function(){
this.style.background='red'
}
divs.onmouseout=function(){
this.style.background=''
}
divs.onclick=function(){
this.style.background='green'
}divs.ondblclick=function(){
this.style.background='blue'
}

代碼要寫權在 window.onload () 或者 document.onready()

❼ js寫touch拖拽事件手指放在要拖動的物體上會迅速閃動怎麼回事

pc上的web頁面滑鼠會產生onmousedown、onmouseup、onmouseout、onmouseover、onmousemove的事件,但是在移動終端如iphone、ipod Touch、ipad上的web頁面觸屏時會產生回ontouchstart、ontouchmove、ontouchend、ontouchcancel事件,分答別對應了觸屏開始、拖拽及完成觸屏事件和取消。

❽ javascript div滑鼠拖動層,閃動問題

可能是你沒有定義left和top,body沒有定義margin:0px一開始默認body是margin:10px,一移動就默認從0,0坐標開始,就縮回去了

❾ JS如果實現border一閃一閃的警示效果

可以的,你通過一個定時器設置2秒鍾就觸發一個事件來改變邊框的顏色就可以達到一閃一閃的效果。要明顯一些的話需要把邊框的寬度設置大一些。

閱讀全文

與js滑鼠閃閃相關的資料

熱點內容
微信文件怎麼填 瀏覽:87
燕十八老師精通mysql視頻教程 瀏覽:255
汽車保養數據怎麼清 瀏覽:629
pdf文件圖像打不開 瀏覽:176
msp430時鍾程序 瀏覽:660
查看sd卡文件系統格式 瀏覽:696
c盤中顯示隱藏文件 瀏覽:951
蘋果升級系統白屏 瀏覽:136
三菱gxplc編程軟體如何使用 瀏覽:710
海康威視手機app怎麼看不了 瀏覽:482
wordpress下載中心插件 瀏覽:402
微信限制字數是多少 瀏覽:20
策劃輸出主要從哪些文件來 瀏覽:174
網路營銷找什麼工作 瀏覽:372
tcl匹配文件名的正則表達式 瀏覽:461
音頻文件數據量為何8 瀏覽:534
有哪些分享學習的網站 瀏覽:174
小程序文件發到微信電腦如何打開 瀏覽:265
四星五星做號工具 瀏覽:920
qq郵箱怎麼發送視頻文件 瀏覽:453

友情鏈接