JS Tips Tip Box Program code

Source: Internet
Author: User
Tags gety

This is a point to text will display text small hint Oh, it is called tips box

function Point (x,y) {this.x=x; this.y=y}
var mloc = new Point (0,0);
Document.onmousemove = MouseMove;
function MouseMove (EV) {
EV = EV | | window.event;
var mousepos = mousecoords (EV);
mloc.x = mousepos.x;
Mloc.y = Mousepos.y;
}
function Mousecoords (EV) {
if (Ev.pagex | | ev.pagey) {return {x:ev.pagex, y:ev.pagey};}
return {X:ev.clientx + document.body.scrollleft-document.body.clientleft,
Y:ev.clienty + document.body.scrolltop-document.body.clienttop};
}
function GetX (Elm) {
var x=0; while (Elm) {x+=elm.offsetleft; elm=elm.offsetparent} return x;
}
function GetY (Elm) {
var y=0;  while (Elm) {y+=elm.offsettop; Elm=elm.offsetparent; } return y;
}
function Showtipfollowmouse (div_id, txt) {
if (Txt.match (/^s*$/)) return;
var Tip=document.getelementbyid (div_id) | | Null
if (!tip) return;
tip.innerhtml = txt;
Tip.style.display = ' block ';
var left = mloc.x + 12;
var top = mloc.y + 12;
if (left+tip.offsetwidth >= document.body.offsetWidth)
left = left-tip.scrollwidth-20;
if (left<0) left=1;
if (top+tip.offsetheight >= document.body.offsetheight+document.body.scrolltop)
top = top-tip.offsetheight-20;
if (top<0) top=1;
if (!document.all) {//ns
Tip.style.left = left + ' px ';
Tip.style.top = top + ' px ';
else {//ie
Tip.style.pixelLeft = left;
Tip.style.pixelTop = top;
}
}
function Hidetip (ID) {
var Tip=document.getelementbyid (id) | | Null
if (tip) tip.style.display= ' none ';
}
Arguments:tip, txt, object, offsetleft, offsettop
function Showtipattop () {
var tip = Arguments[0] | | Null
var txt = arguments[1] | | '';
var obj = arguments[2] | | Null
var offsetleft = arguments[3] | | 0;
var offsettop = arguments[4] | | 0;
tip = (typeof tip = = ' object ')? Tip:document.getElementById (tip) | | Null
if (!tip) return;
if (Txt.match (/^s*$/)) return;
obj = (typeof obj = = ' object ')? Obj:document.getElementById (obj) | | Null
tip.innerhtml = txt;
Tip.style.display = ' block ';
var left = GetX (obj)-offsetleft;
var top = GetY (obj)-tip.offsetheight-offsettop;
if (left+tip.offsetwidth >= document.body.offsetWidth)
left = left-tip.offsetwidth+ (Obj.offsetwidth | | 0);
if (left<0) left=1;
if (!document.all) {//ns
Tip.style.left = left + ' px ';
Tip.style.top = top + ' px ';
else {//ie
Tip.style.pixelLeft = left;
Tip.style.pixelTop = top;
}
}
function Showtipatbottom () {
var tip = Arguments[0] | | Null
var txt = arguments[1] | | '';
var obj = arguments[2] | | Null
var offsetleft = arguments[3] | | 0;
var offsettop = arguments[4] | | 0;
tip = (typeof tip = = ' object ')? Tip:document.getElementById (tip) | | Null
if (!tip) return;
if (Txt.match (/^s*$/)) return;
obj = (typeof obj = = ' object ')? Obj:document.getElementById (obj) | | Null
tip.innerhtml = txt;
Tip.style.display = ' block ';
var left = GetX (obj) + offsetleft;
var top = GetY (obj) + tip.offsetheight + offsettop;
if (left+tip.offsetwidth >= document.body.offsetWidth)
left = left-tip.offsetwidth+ (Obj.offsetwidth | | 0);
if (left<0) left=1;
if (!document.all) {//ns
Tip.style.left = left + ' px ';
Tip.style.top = top + ' px ';
else {//ie
Tip.style.pixelLeft = left;
Tip.style.pixelTop = top;
}
}
function Showlayeratbottom () {
var tip = Arguments[0] | | Null
var obj = arguments[1] | | Null
var offsetleft = arguments[2] | | 0;
var offsettop = arguments[3] | | 0;
tip = (typeof tip = = ' object ')? Tip:document.getElementById (tip) | | Null
if (!tip) return;
obj = (typeof obj = = ' object ')? Obj:document.getElementById (obj) | | Null
Tip.style.display = ' block ';
var left = GetX (obj) + offsetleft;
var top = GetY (obj) + obj.offsetheight + offsettop;
if (!document.all) {//ns
Tip.style.left = left + ' px ';
Tip.style.top = top + ' px ';
else {//ie
Tip.style.pixelLeft = left;
Tip.style.pixelTop = top;
}
}
var tipstring = ' <strong> access <font color= #FF6800 ><SITE></font>, please <font color= #ff6800 > Return to this page to apply </font>,<BR> no need to register, release resumes. </strong> ';
var tipstring = ' <strong><span style= ' color: #FF6800; font-size:18px; " > Please return to this page to apply </span><BR> to publish your CV at this site, and do not need to register with other websites. </strong> ';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.