Loading ...
Sorry, an error occurred while loading the content.
 

Re: [ydn-javascript] Dom.setStyle () causes exception when setting opacity

Expand Messages
  • Matt Sweeney
    Hi evanchu, The current implementation of setStyle() only allows you to set opacity for IE when an element is part of the document. This will be fixed in the
    Message 1 of 2 , Apr 13, 2006
      Hi evanchu,

      The current implementation of setStyle() only allows you to set opacity
      for IE when an element is part of the document. This will be fixed in
      the next release.

      One workaround is to append your new img before setting opacity.

      If you want to fix your local version, change the following (from
      Dom.setStyle):

      if (el.filters) {
      el.style.filter = 'alpha(opacity=' + val * 100 + ')';

      to:

      if (typeof el.style.filter == 'string') {
      el.style.filter = 'alpha(opacity=' + val * 100 + ')';

      Matt

      evanchu wrote:

      >I searched this group and have not found any mention of the following
      >observation. Given the following code:
      >
      >var mNewImage = new Image ();
      >try
      >{
      > //the follows will fail on IE
      > YAHOO.util.Dom.setStyle (mNewImage, "opacity", 0);
      > alert ("1");
      >}
      >catch (e)
      >{
      > mNewImage.style.filter = "alpha(opacity=0)"; //IE only
      > alert ("2");
      >}
      >
      >
      >When executed on IE 6, YAHOO.util.Dom.setStyle() causes an exception
      >because mNewImage.filters does not exist. The workaround is to
      >execute the catch block.
      >
      >
      >
      >
      >
      >
      >Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.