js 鼠標(biāo)移動顯示圖片的簡單實(shí)例
一、js代碼
//***********默認(rèn)設(shè)置定義.*********************
tPopWait=50;//停留tWait豪秒后顯示提示。
tPopShow=5000;//顯示tShow豪秒后關(guān)閉提示
showPopStep=20;
popOpacity=99;
//***************內(nèi)部變量定義*****************
sPop=null;
curShow=null;
tFadeOut=null;
tFadeIn=null;
tFadeWaiting=null;
document.write("<mce:style type='text/css'id='defaultPopStyle'><!--
");
document.write(".cPopText { line-break : normal;word-break : break-all ; background-color: #FEFCF3;color:#000000; border: 1px #E7B68C solid;padding-top: 2px; padding-right: 4px; padding-left: 4px; padding-bottom: 2px;font-size: 12px;width:96px; filter: Alpha(Opacity=0)}");
document.write("
--></mce:style><style type='text/css'id='defaultPopStyle' mce_bogus="1">");
document.write(".cPopText { line-break : normal;word-break : break-all ; background-color: #FEFCF3;color:#000000; border: 1px #E7B68C solid;padding-top: 2px; padding-right: 4px; padding-left: 4px; padding-bottom: 2px;font-size: 12px;width:96px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' style="position:absolute;z-index:1000;" mce_style="position:absolute;z-index:1000;" class='cPopText'></div>");
function showPopupText(){
var o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
if(o.dypop!=sPop) {
sPop=o.dypop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
if(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="Alpha()";
dypopLayer.filters.Alpha.opacity=0;
}
else {
if(o.dyclass!=null) popStyle=o.dyclass
else popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}
}
}
function showIt(){
dypopLayer.className=popStyle;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
else popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
else popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}
function fadeOut(){
if(dypopLayer.filters.Alpha.opacity<popOpacity) {
dypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
}
else {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
}
}
function fadeIn(){
if(dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
}
}
document.onmouseover=showPopupText;
二、html代碼包含js代碼即可,使用范例
<a href="../UpLoadFile/200911784060017.jpg" target="_blank" title="<img src=../UpLoadFile/200911784060017.jpg />">大</a> <a href="../UpLoadFile/200911784060018.jpg" target="_blank" title="<img src=../UpLoadFile/200911784060018.jpg width=96 height=70 />">小</a>

- 基于JavaScript實(shí)現(xiàn)鼠標(biāo)箭頭移動圖片跟著移動
- JavaScript簡單實(shí)現(xiàn)鼠標(biāo)移動切換圖片的方法
- js圖片跟隨鼠標(biāo)移動代碼
- javascript實(shí)現(xiàn)圖片跟隨鼠標(biāo)移動效果的方法
- js根據(jù)鼠標(biāo)移動速度背景圖片自動旋轉(zhuǎn)的方法
- js實(shí)現(xiàn)跟隨鼠標(biāo)移動且?guī)шP(guān)閉功能的圖片廣告實(shí)例
- JS實(shí)現(xiàn)鼠標(biāo)移動到縮略圖顯示大圖的圖片放大效果
- JavaScript 控制圖片改變重疊順序的代碼(鼠標(biāo)移動切換)
- js鼠標(biāo)移動在title中顯示圖片的效果代碼
- js實(shí)現(xiàn)鼠標(biāo)左右移動,圖片也跟著移動效果
相關(guān)文章
for 循環(huán)性能比較 提高for循環(huán)的效率
性能有較大的區(qū)別嗎,有必要采取這種寫法嗎2009-03-03javascript中使用new與不使用實(shí)例化對象的區(qū)別
這篇文章主要介紹了javascript中使用new與不使用實(shí)例化對象的區(qū)別的相關(guān)資料,需要的朋友可以參考下2015-06-06JS表格組件神器bootstrap table詳解(基礎(chǔ)版)
這篇文章主要介紹了JS表格組件神器bootstrap table,bootstrap table界面采用扁平化的風(fēng)格,用戶體驗(yàn)比較好,更好兼容各種客戶端,需要了解更多bootstrap table的朋友可以參考下2015-12-12javascript:history.go()和History.back()的區(qū)別及應(yīng)用
為提高用戶體驗(yàn)度,可能會使用到刷新 前進(jìn) 后退等相關(guān)更能,本文將以此問題詳細(xì)介紹javascript:history.go()和History.back()的區(qū)別及應(yīng)用,需要的朋友可以參考下2012-11-11layui lay-verify form表單自定義驗(yàn)證規(guī)則詳解
今天小編就為大家分享一篇layui lay-verify form表單自定義驗(yàn)證規(guī)則詳解,具有很好的參考價(jià)值,相信我對大家有所幫助。一起跟隨小編過來看看吧2019-09-09