1.โค้ด js
คัดลอกรหัสรหัสดังต่อไปนี้:
//****************** คำจำกัดความการตั้งค่าเริ่มต้น **********************
tPopWait=50;//แสดงข้อความแจ้งหลังจากอยู่ใน tWait เป็นเวลามิลลิวินาที
tPopShow=5000;//ปิดพร้อมท์หลังจากแสดง tShow เป็นมิลลิวินาที
showPopขั้นตอน=20;
ป๊อปความทึบ=99;
//****************** คำจำกัดความของตัวแปรภายใน******************
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 ; สีพื้นหลัง: #FEFCF3;color:#000000; border: 1px #E7B68C solid;padding-top: 2px; padding-right : 4px; padding-left: 4px; padding-bottom: 2px; 12px;ความกว้าง:96px; ตัวกรอง: อัลฟ่า(ความทึบ=0)}");
เอกสาร.write("
--></mce:style><style type='text/css'id='defaultPopStyle' mce_bogus="1">");
document.write(".cPopText { line-break : Normal;word-break : break-all ; สีพื้นหลัง: #FEFCF3;color:#000000; border: 1px #E7B68C solid;padding-top: 2px; padding-right : 4px; padding-left: 4px; padding-bottom: 2px; 12px;ความกว้าง:96px; ตัวกรอง: อัลฟ่า(ความทึบ=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> ");
ฟังก์ชั่น showPopupText(){
var o=event.srcElement;
MouseX=เหตุการณ์.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=""};
ถ้า (o.dypop! = sPop) {
sPop=o.dypop;
ชัดเจนหมดเวลา(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);
ถ้า(sPop==null || sPop=="") {
dypopLayer.innerHTML="";
dypopLayer.style.filter="อัลฟ่า()";
dypopLayer.filters.Alpha.opacity=0;
-
อื่น {
ถ้า(o.dyclass!=null) popStyle=o.dyclass
อย่างอื่น popStyle = "cPopText";
curShow=setTimeout("showIt()",tPopWait);
-
-
-
ฟังก์ชั่น showIt(){
dypopLayer.className=ป๊อปสไตล์;
dypopLayer.innerHTML=sPop;
popWidth=dypopLayer.clientWidth;
popHeight=dypopLayer.clientHeight;
ถ้า(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
อย่างอื่น popLeftAdjust=0;
ถ้า (MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
อย่างอื่น popTopAdjust=0;
dypopLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
dypopLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
dypopLayer.style.filter="อัลฟ่า(ความทึบ=0)";
จางหายไป();
-
ฟังก์ชั่น fadeOut(){
ถ้า (dypopLayer.filters.Alpha.opacity<popOpacity) {
dypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
-
อื่น {
dypopLayer.filters.Alpha.opacity=popOpacity;
tFadeWaiting=setTimeout("fadeIn()",tPopShow);
-
-
ฟังก์ชั่น fadeIn(){
ถ้า (dypopLayer.filters.Alpha.opacity>0) {
dypopLayer.filters.Alpha.opacity-=1;
tFadeIn=setTimeout("fadeIn()",1);
-
-
document.onmouseover=showPopupText;
2. รหัส html จำเป็นต้องมีโค้ด js เท่านั้น ตัวอย่างการใช้งาน
<a href="../UpLoadFile/200911784060017.jpg" target="_blank">ใหญ่</a><a href="../UpLoadFile/200911784060018.jpg" target="_blank">เล็ก</a>