js鼠標(biāo)移動(dòng)在title中顯示圖片的效果代碼
更新時(shí)間:2009年11月29日 21:47:31 作者:
當(dāng)鼠標(biāo)移動(dòng)時(shí),在title提示框中,顯示出設(shè)定的圖片。
1.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("<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:468px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' 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;
2.html代碼包含js代碼即可,使用范例
具體的看腳本之家給出的測(cè)試代碼。
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
復(fù)制代碼 代碼如下:
//***********默認(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("<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:468px; filter: Alpha(Opacity=0)}");
document.write("</style>");
document.write("<div id='dypopLayer' 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;
2.html代碼包含js代碼即可,使用范例
具體的看腳本之家給出的測(cè)試代碼。
[Ctrl+A 全選 注:引入外部Js需再刷新一下頁(yè)面才能執(zhí)行]
您可能感興趣的文章:
- js控制鼠標(biāo)事件移動(dòng)及移出效果顯示
- JS實(shí)現(xiàn)鼠標(biāo)移動(dòng)到縮略圖顯示大圖的圖片放大效果
- javascript實(shí)現(xiàn)圖片跟隨鼠標(biāo)移動(dòng)效果的方法
- js鼠標(biāo)移動(dòng)時(shí)禁止選中文字
- js+html+css實(shí)現(xiàn)鼠標(biāo)移動(dòng)div實(shí)例
- JavaScript獲取鼠標(biāo)移動(dòng)時(shí)的坐標(biāo)(兼容IE8、chome谷歌、Firefox)
- js實(shí)現(xiàn)鼠標(biāo)左右移動(dòng),圖片也跟著移動(dòng)效果
- js實(shí)現(xiàn)文字跟隨鼠標(biāo)移動(dòng)而移動(dòng)的方法
- js圖片跟隨鼠標(biāo)移動(dòng)代碼
- JS實(shí)現(xiàn)鼠標(biāo)移動(dòng)拖尾
相關(guān)文章
js實(shí)現(xiàn)運(yùn)動(dòng)logo圖片效果及運(yùn)動(dòng)元素對(duì)象sportBox使用方法
Js實(shí)現(xiàn)運(yùn)動(dòng)的圖片特效,兩個(gè)網(wǎng)站Logo快速運(yùn)動(dòng)類似顯示器屏保。借此練習(xí)運(yùn)動(dòng)元素對(duì)象sportBox的使用方法,需要了解的朋友可以參考下2012-12-12javascript預(yù)覽上傳圖片發(fā)現(xiàn)的問(wèn)題的解決方法
前段時(shí)間做一個(gè)行業(yè)站點(diǎn),其中商鋪有一塊功能是商鋪設(shè)置功能,要求是進(jìn)行版式,企業(yè)名稱,企業(yè)頭部LOGO,企業(yè)頭部背景進(jìn)行自定義設(shè)置。2010-11-11感應(yīng)鼠標(biāo)的圖片遮罩動(dòng)畫(huà)效果
感應(yīng)鼠標(biāo)的圖片遮罩動(dòng)畫(huà)效果,鼠標(biāo)放上后會(huì)動(dòng)畫(huà)顯示文字提示,有意思哦,有興趣的朋友運(yùn)行一下看效果。2010-10-10javascript入門·圖片對(duì)象(無(wú)刷新變換圖片)\滾動(dòng)圖像
javascript入門·圖片對(duì)象(無(wú)刷新變換圖片)\滾動(dòng)圖像...2007-10-10javascript動(dòng)態(tài)改變img的src屬性圖片不顯示的解決方法
最近寫(xiě)了幾句javascript程序代碼,涉及到了動(dòng)態(tài)改變圖片的效果,結(jié)果在ie下顯示不出了來(lái),實(shí)在是郁悶,上網(wǎng)找尋結(jié)果,終于發(fā)現(xiàn)了,原來(lái)是 瀏覽器的問(wèn)題。現(xiàn)在將方法貼出來(lái)分享。2010-10-10一個(gè)不錯(cuò)的給圖片添加說(shuō)明文字的動(dòng)態(tài)層的實(shí)現(xiàn)代碼
一個(gè)不錯(cuò)的給圖片添加說(shuō)明文字的動(dòng)態(tài)層的實(shí)現(xiàn)代碼,需要的朋友可以參考下2013-04-04