[thelist] DHTML in frames

Martin Burns martin at easyweb.co.uk
Sat, 14 Aug 1999 12:08:42 +0100


I'm putting in the tooltip script (below) for NS users. It works
beautifully at
http://www.easyweb.co.uk/elemental/gigs/
but not when it's in a frame:
http://www.funkmusic.co.uk/gigs/


Any solutions? As I'm at home, responses to me
at martin@easyweb.co.uk would be appreciated

Cheers
Martin

 /* The HTML tip handling code adapted from the code found at
     at Inside Dynamic HTML: HTTP://www.insideDHTML.com
 */

 // Support for all collection
 var allSupport = document.all!=null

 function setupEventObject(e) {
   // Map NS event object to IEs
   if (e==null) return // IE returns
   window.event = e
   window.event.fromElement = e.target
   window.event.toElement = e.target
   window.event.srcElement = e.target
   window.event.x = e.x
   window.event.y = e.y
   // Route the event to the original element
   // Necessary to make sure _tip is set.
   window.event.srcElement.handleEvent(e);
 }

 function checkName(src) {
   // Look for tooltip in IE
   while ((src!=null) && (src._tip==null))
     src = src.parentElement
   return src
 }

 function getElement(elName) {
   // Get an element from its ID
     return document.layers[elName]
 }

  function writeContents(el, tip) {
   // Replace the contents of the tooltip
     el.document.open()
     el.document.write("<TABLE WIDTH=150 BORDER='0'><TR><TD WIDTH='100%' 
BGCOLOR='#ffcc33'><font face='Verdana, Arial, Helvetica, sans-serif' 
size='1' color='#000000'>")
     el.document.write(tip)
     el.document.write("</font></TD></TR></TABLE>")
     el.document.close()   
 }
 
 function setPosition(el) {
   // Set the position of an element
   src = window.event.srcElement
   el.top = src.y + 20
   el.left = src.x
 }

 function setVisibility(el, bDisplay) {
   // Hide or show to tip
   if (bDisplay)    
       el.visibility = "show";
   else
       el.visibility = "hidden"
 }

 function displayContents(tip) {
   // Display the tooltip.
   var el = getElement("tipBox")
   writeContents(el, tip)
   setPosition(el)
   setVisibility(el, true)
 }

 function doMouseOver(e) {
   // Mouse moves over an element
   setupEventObject(e)
   var el, tip
   if ((el = checkName(window.event.srcElement))!=null)
     if  (!el._display) {
       displayContents(el._tip)
       el._display = true
     }
 }

 function doMouseOut(e) {
   // Mouse leaves an element
   setupEventObject(e)
   el = checkName(window.event.srcElement)
   var el, tip
   if ((el = checkName(window.event.srcElement))!=null)
     if (el._display)
       if ((el.contains==null) || (!el.contains(window.event.toElement))) 
{
         setVisibility(getElement("tipBox"), false)
         el._display = false
       }
 }

 function doLoad() {
   // Do Loading
   if ((window.document.captureEvents==null) && (!allSupport))
     return // Not IE4 or NS4
   if (window.document.captureEvents!=null)  // NS - capture events
     window.document.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT)
   window.document.onmouseover = doMouseOver;
   window.document.onmouseout = doMouseOut;
 }

 if(!allSupport) {window.onload = doLoad}






Now at our new office:

------------------------------------------------------------------------
 EASYweb Design - professional Web Design that speaks *your* language
    email: info@easyweb.co.uk           snailmail: 30 Shandon Place
      tel: +44 (0)131 623 0266                     Edinburgh, Scotland
pricelist: prices@easyweb.co.uk  terms&conditions: terms@easyweb.co.uk
------------------------------------------------------------------------
  Cynical about New Britain? Have a look at www.easyweb.co.uk/uturns/