javascript pop up prompt box effect with text information

  • 2021-07-04 17:57:15
  • OfStack

This paper describes the effect of javascript pop-up prompt box with text information. Share it for your reference, as follows:

tooltips.js:


// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety = 8;
function newelement(newid)
{
  if(document.createElement)
  {
    var el = document.createElement('div');
    el.id = newid;
    with(el.style)
    {
      display = 'none';
      position = 'absolute';
    }
    el.innerHTML = ' ';
    document.body.appendChild(el);
  }
}
var ie5 = (document.getElementByIdx && document.all);
var ns6 = (document.getElementByIdx && !document.all);
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf('applewebkit') != -1 ? 1 : 0);
function getmouseposition(e)
{
  if(document.getElementByIdx)
  {
    var iebody=(document.compatMode &&
    document.compatMode != 'BackCompat') ?
    document.documentElement : document.body;
    pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
    pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
    mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
    mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;
    var lixlpixel_tooltip = document.getElementByIdx('tooltip');
    lixlpixel_tooltip.style.left =(mousex+pagex+offsetx) + 'px';
 lixlpixel_tooltip.style.top =(mousey+pagey+offsety) + 'px';
  }
}
function tooltip(tip)
{
  if(!document.getElementByIdx('tooltip')) newelement('tooltip');
  var lixlpixel_tooltip = document.getElementByIdx('tooltip');
  lixlpixel_tooltip.innerHTML = tip;
  lixlpixel_tooltip.style.display = 'block';
  document.onmousemove = getmouseposition;
}
function exit()
{
  document.getElementByIdx('tooltip').style.display = 'none';
}

test.html


<html>
<head>
<style>
.tableBorder7{width:800;solid; background-color: #000000;}
TD{font-family:  Song Style ;font-size: 12px;line-height : 15px ;}
th{background-color: #f7f7f7;color: #000000;font-size: 12px;font-weight:bold;}
th.th1{background-color: #333333;}
td.TableBody7{background-color: #B1EA45;}
</style>
<script language="JavaScript" src='tooltips.js'>
</script>
</HEAD>
<BODY>
<div onmouseover="tooltip(' If you add 1 Podcasts ( Podcast ), select this check box. ');"onmouseout="exit();"> Butterfly Lovers </div>
</BODY>
</HTML>

More readers interested in JavaScript can check the topics of this site: "JavaScript prompt box effect summary", "JavaScript switching special effects and skills summary", "JavaScript search algorithm skills summary", "JavaScript animation special effects and skills summary", "JavaScript error and debugging skills summary", "JavaScript data structure and algorithm skills summary", "JavaScript traversal algorithm and skills summary" and "JavaScript mathematical operation usage summary"

I hope this article is helpful to everyone's JavaScript programming.


Related articles: