faqts : Computers : Programming : Languages : JavaScript : Windows

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 21 people (81%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How to place a window relative to an event occuring?

Mar 16th, 2001 04:01
Martin Honnen,


In the HTML event handler use the
  event
object with its
  event.screenX/screenY
properties which are supported in NN4, NN6 and IE4+.

Example:

<HTML>
<HEAD>
<SCRIPT>
function openTipWindow (evt, tip) {
  var x = evt.screenX;
  var y = evt.screenY;
  var w = open ('', 'tipWin', 
                'width=100,height=100,screenX=' 
                 + x + ',left=' + x
                 + ',screenY=' + y + ',top=' + y 
                 + ',resizable=1,scrollbars=1');
  w.document.open();
  w.document.write(
  '<HTML><BODY SCROLL="auto" ONBLUR="window.close();"' 
  + ' BGCOLOR="lightyellow">' 
  + '<TABLE WIDTH="100%" HEIGHT="100%"><TR>' 
  + '<TD ALIGN="center" VALIGN="middle">' 
  + '<B>' + tip + '<\/B>' 
  + '<\/TD><\/TR><\/TABLE><\/BODY><\/HTML>');
  w.document.close();
  return w;
}
</SCRIPT>
</HEAD>
<BODY>
<A HREF="http://www.kibo.com";
   ONMOUSEOVER="openTipWindow(event, 'Visit Kibo');"
>
Visit God
</A>
<BR>
<A HREF="news:alt.religion.kibology"
   ONMOUSEOVER="openTipWindow(event, 'Visit a.r.k.');"
>
Goto Heaven
</A>

</BODY>
</HTML>