Hi all. I have built a button widget that I use on the following site - www.arrayx.co.uk/problem_test
 
The widget is used in the left-hand pane, to display the dates, the days and the months. The strange thing is, when the page loads initially, all is fine. The mouse over images are all pre-loaded and work as intended. However, if you press the button 'Search the Listings', then click on 'Add New Event' at the top of the page, then close the window that this opens, you will find that the browser seems to have lost all the images that were loaded in the left hand pane. If you mouseover them, the browser will fetch both images again from the server - the onmouseover image and the onmouseout image (which is weird seeing as though it's already being displayed).
 
Can anyone help me work out what is going on here? The code for the button widget is below...
 
As an aside, this is running on 2.52. Should I delete the this.id=.. line? What about the superclass lines?
 
Cheers, Ben
 
--------------------code start---------------------
 
DynLayer.prototype.setBckGrdImg=function(obj) {
 this.bgImage=obj+'.src';
 if (this.css==null) return;
 if (is.ns4) {
  this.elm.background.src="obj.src;  if (!obj) this.setBgColor(this.getBgColor());
 }
 else this.css.backgroundImage='url('+obj.src+')';
};
 
activeDayOn = new Image()
activeDayOn.src = " 'images/left_nav/on_01.gif'activeDayOff = new Image()
activeDayOff.src = " 'images/left_nav/off_01.gif'
 
function button(x,y,w,h,caption,imgOn,imgOff,month,year,date1,date2,date3,date4,date5,isDay) {
 this.superClass=DynLayer
 this.superClass()
 this.id="button"+(button.Count++)
 
 this.moveTo(x||0,y||0)
 this.setSize(w||0,h||0)
 
 this.caption=caption||''
 
 if (isDay!=true) {
  this.imgDir='images/left_nav/'
  this.imgOn = new Image()
  this.imgOn.src="this.imgDir+imgOn  this.imgOff = new Image()
  this.imgOff.src="this.imgDir+imgOff }
 
 this.date1=date1
 this.date2=date2
 this.date3=date3
 this.date4=date4
 this.date5=date5
 
 this.selected=false
 
 var l=new EventListener(this)
 l.oncreate=function(e) {
  var o=e.getTarget()
  
  if (isDay) {
   o.setBckGrdImg(activeDayOff)
  } else {
   o.setBckGrdImg(o.imgOff)  
  }
  
  o.dyncaption=new DynLayer(null,0,0,o.w,o.h)
  
  if (o.caption.length>2) o.caption=''
  
  o.dyncaption.setHTML('<center class=\'textSnippets\'>'+o.caption+'</center>')
 
  o.addChild(o.dyncaption)
  o.setVisible(true)
  
  o.dynTopLayer=new DynLayer(null,0,0,o.w,o.h)
  o.addChild(o.dynTopLayer)
  o.setVisible(true)
 }
 
 l. {
  var o = e.getTarget()
  if (month) {
   freeText = parent.frames[2].document.listing_crit.freeText.value;
   
   //split the freeText string into array elements by space
   freeText = freeText.split(" ");
   var strFreeText = "";
   
   //construct the strFreeText string which inserts ~ where there was spaces
   for (x=0; x<freeText.length; x = x + 1)
   {
    if (x==freeText.length-1)
    {
     //don't append a ~ if this is the last array element
     strFreeText += freeText[x];   
    }
    else
    {
     strFreeText += freeText[x] + "~";   
    }
   }
   
   //delete the trailing ~
      while (strFreeText.substring(strFreeText.length-1,strFreeText.length) == ' ')
         {
    strFreeText = strFreeText.substring(0, strFreeText.length-1);
   }
   
   //encode strFreeText in case of special characters
   strFreeText = escape(strFreeText);
   
   area = parent.frames[2].document.listing_crit.area.selectedIndex;
   category = parent.frames[2].document.listing_crit.category.selectedIndex;
 
   if (year) {
    parent.navFrame.location="cl_nav.php?month="+month+"&year="+year+"&freeText="+strFreeText+"&area="+area+"&category="+category;
   } else {
    parent.navFrame.location="cl_nav.php?month="+month+"&freeText="+strFreeText+"&area="+area+"&category="+category;
   }
  } else {
   if (isDay) {
    o.selected?o.setBckGrdImg(activeDayOff):o.setBckGrdImg(activeDayOn)
    o.selected?o.selected=false:o.selected=true
   } else {
    o.selected?o.setBckGrdImg(o.imgOff):o.setBckGrdImg(o.imgOn)
    o.selected?o.selected=false:o.selected=true   
   }
   //alert(o)
  }
  
  if (o.caption=='') {
   if (o.date1) {
    if (o.selected) {
     eval('myButton'+date1+'.selected=true')
     eval('myButton'+date1+'.setBckGrdImg(activeDayOn)')
    } else {
     eval('myButton'+date1+'.selected=false')
     eval('myButton'+date1+'.setBckGrdImg(activeDayOff)')   
    }
   }
   if (o.date2) {
    if (o.selected) {
     eval('myButton'+date2+'.selected=true')
     eval('myButton'+date2+'.setBckGrdImg(activeDayOn)')
    } else {
     eval('myButton'+date2+'.selected=false')
     eval('myButton'+date2+'.setBckGrdImg(activeDayOff)')   
    }
   }
   if (o.date3) {
    if (o.selected) {
     eval('myButton'+date3+'.selected=true')
     eval('myButton'+date3+'.setBckGrdImg(activeDayOn)')
    } else {
     eval('myButton'+date3+'.selected=false')
     eval('myButton'+date3+'.setBckGrdImg(activeDayOff)')   
    }
   }
   if (o.date4) {
    if (o.selected) {
     eval('myButton'+date4+'.selected=true')
     eval('myButton'+date4+'.setBckGrdImg(activeDayOn)')
    } else {
     eval('myButton'+date4+'.selected=false')
     eval('myButton'+date4+'.setBckGrdImg(activeDayOff)')   
    }
   }
   if (o.date5) {
    if (o.selected) {
     eval('myButton'+date5+'.selected=true')
     eval('myButton'+date5+'.setBckGrdImg(activeDayOn)')
    } else {
     eval('myButton'+date5+'.selected=false')
     eval('myButton'+date5+'.setBckGrdImg(activeDayOff)')   
    }
   }
  }
 }
 
 l. {
  var o=e.getTarget()
  
  if (isDay) {
   o.selected?'':o.setBckGrdImg(activeDayOn)
  } else {
   o.selected?'':o.setBckGrdImg(o.imgOn)  
  }
  
  o.css.cursor='hand'
 }
 
 l. {
  var o=e.getTarget()
  
  if (isDay) {
   o.selected?'':o.setBckGrdImg(activeDayOff)  
  } else {
   o.selected?'':o.setBckGrdImg(o.imgOff)  
  }
  
  //o.css.cursor='normal'
 }
 
 this.addEventListener(l)
 
 return this
}
button.Count=0
button.prototype=new DynLayer()
button.prototype.getSubClass=function() { return button }
 
----------------code finish-------------------------
 
 
================================================================
 
= Array[x] =
= delivering design aware programming solutions =
= www.arrayx.co.uk = = [EMAIL PROTECTED] =
= +44 (0)7780 696840 = = 1 Flintham Drive, Sherwood, Notts. NG5 3DS UK =
 
STANDARD DISCLAIMER: This message is confidential. You should not copy it or
disclose its contents to anyone. You may use and apply the information only
for the intended purpose. Internet communications are not secure and
therefore Array[x] does not accept legal responsibility for the contents of this
message. Any views or opinions presented are only those of the author and
not those of Array[x]. If this email has come to you in error please delete it and
any attachments.
 

--------------------------------------------------------------------------------
 

---
Outgoing mail is certified Virus Free using AVG version 6.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.255 / Virus Database: 128 - Release Date: 17/05/2001

Reply via email to