Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

popup location (should be simple)

Status
Not open for further replies.

verbum

Technical User
Oct 25, 2000
1
IL
Using a script to popup message boxes when "onMouseOver"
event occurs.
Problem is that the box pops up at a seamingly random location, sometimes outside the window and thus not visible. I would like the box to open near the
mouse-pointer.

These are the scripts involved:

Code:
<!-- Begin
function setupDescriptions()
{
  var x = navigator.appVersion;
  y = x.substring(0,4);
  if (y>=4) setVariables();
}

var x,y,a,b;
function setVariables()
{
  h=&quot;.pixelLeft=&quot;;
  v=&quot;.pixelTop=&quot;;
  dS=&quot;&quot;;
  sD=&quot;.style&quot;;
}

function popLayer(a)
{
  desc = &quot;<table cellpadding=0 border=1 &quot;;
  if (a==0)
  {
    desc += 
    &quot;bgcolor=A7A7FF>    <td> ... Message 1 ...&quot;;
  }
  
 if (a==1)
  {
    desc += 
    &quot;bgcolor=A7A7FF>    <td> Message 2.&quot;;
  }
<!-- etcetera  
  if (a==2)
  {
    desc += 
    &quot;bgcolor=A7FFA7> <td> message 3. &quot;;
  }
...
-->
  desc += &quot;</td></table>&quot;;
  object1.innerHTML=desc;
  eval(dS+&quot;object1&quot;+sD+h+(x+25));
  eval(dS+&quot;object1&quot;+sD+v+y);
}

function hideLayer(a)
{
  object1.innerHTML=&quot;&quot;;
}

function handlerMM(e)
{
 x =  event.clientX;
 y =  event.clientY;
}

document.onmousemove = handlerMM;
//  End -->
</script>

<!-- INVOCATION IN THE body IS AS FOLLOWS:


onMouseOver=&quot;popLayer(1)&quot; onMouseOut=&quot;hideLayer(-50)&quot; 

. . . IN OTHER PARTS popLayer(1) IS REPLACED BY
      popLayer(2)  ETC.

-->

Thanks !
 
Do you have div tags within the html? That can throw off where the popup is place if it is relatively positioned. Also, the clientX, clientY return the mouse position relative to to the inside left corner of the browser window. If the scroll bars aren't at the zero position this will throw off where you place your popup.

Later,

Rob
robschultz@yahoo.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

&quot;Focus on the solution to the problem,

not the obstacles in the way.&quot;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top