導航:首頁 > 編程語言 > 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滑鼠閃閃相關的資料

熱點內容
怎麼把ps文件變成源文件 瀏覽:807
如何把圖片放進這個文件夾 瀏覽:530
誰有qq認證圖標復制 瀏覽:881
2014年web伺服器測試工具 瀏覽:192
win7鏡像文件怎麼用 瀏覽:983
多數據can怎麼發送 瀏覽:997
什麼是夏威夷果種植技術app 瀏覽:160
上海學習編程哪個地方好 瀏覽:958
股票軟體與交易編程軟體哪個好 瀏覽:216
linux如何查看一個文件的位置 瀏覽:911
c頭文件無法打開源文件stdafx 瀏覽:750
蘋果x的桌面上可以建文件夾 瀏覽:368
ug8532位破解版安裝教程 瀏覽:490
電腦網路如何重新驅動 瀏覽:125
win10連接伺服器命令 瀏覽:228
盧克raid活動20升級卷 瀏覽:969
機票預訂什麼網站好 瀏覽:690
讀寫xml配置文件 瀏覽:153
java爬蟲解析html 瀏覽:861
約瑟夫集合java 瀏覽:275

友情鏈接