Changing opacity using setTimeout or setInterval

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kong Chun Ho
    New Member
    • Jul 2010
    • 34

    Changing opacity using setTimeout or setInterval

    Hi,
    My sctipt not work, it can't change opacity every 0.1 second!

    Code:
    function LiveSupport() {
    var x = document.getElementById('c_cover');
    var y = document.getElementById('c_popcontent');
    var z;
    var startOpacity = '0'; //int only
    var endOpacity = '80'; //int only
    var t = 0;
    x.style.position = 'absolute';
    x.style.top = '80px';
    x.style.left = '50%';
    x.style.marginLeft = '-325px';
    x.style.background = '#000';
    x.style.zIndex = '998';
    x.style.height = '676px';
    x.style.width = '650px';
    x.style.opacity=startOpacity/100;
    x.style.filter = "alpha(opacity=" + startOpacity + ")";
    for (z=startOpacity; z!=endOpacity; z++) {
    t++;
    setTimeout(function () { setOpacity('c_cover', z); }, t+'0');
    }
    }
    i have alerted t, it didn't change black(the element) when it alerted(1-79), when var t was 80, it changed to opacity 0.8!, so where is 0.01-0.79???

    Thanks.
  • Kong Chun Ho
    New Member
    • Jul 2010
    • 34

    #2
    Any one have solution?

    Comment

    • omerbutt
      Contributor
      • Nov 2006
      • 638

      #3
      please paste your complete code along with the html if you want someone to look at it and advise nad you have an error change this line no 17
      with this one
      Code:
      x.style.filter = "alpha(opacity= " +startOpacity + ")";

      Comment

      • Kong Chun Ho
        New Member
        • Jul 2010
        • 34

        #4
        Code:
        <div id = "contact">
        <p class = "heading">Contact us if you have question or you have feedback to us</p>
        <p class = "Subheading">Live support</p>
        <?
        $current = "http://messenger.services.live.com/users/7a2131078a356d3@apps.messenger.live.com/presenceimage?mkt=zh-tw";
        $current = file_get_contents($current);
        $online = "http://www.wlmessenger.net/static/img/presence/Online.gif";
        $online = file_get_contents($online);
        $offline = "http://www.wlmessenger.net/static/img/presence/Offline.gif";
        $offline = file_get_contents($offline);
        if($current == $online) {
        echo '<a href = "#" style = "color:#666;" onmouseover = "this.style.color = \'#999\'" onmouseout = "this.style.color = \'#666\';" onclick = "LiveSupport();">Live support is online, please click here to talk with our support live.</a>';
        }else if($current == $offline) {
        echo 'Live support is offline, please use helpdesk to contact support.';
        }
        ?>
        <p></p>
        <p class = "Subheading">Helpdesk</p>
        <p><a style = "color:#666;" onmouseover = "this.style.color = '#999'" onmouseout = "this.style.color = '#666';" href = "?a=h">Submit a ticket (Reply in 72 hour)</a></p>
        <p><a style = "color:#666;" onmouseover = "this.style.color = '#999'" onmouseout = "this.style.color = '#666';" href = "?a=t">Track your submitted ticket</a></p>
        <div id = "c_cover"></div>
        <div id = "c_popcontent"></div>
        </div>

        Comment

        • Kong Chun Ho
          New Member
          • Jul 2010
          • 34

          #5
          add &nbsp;?
          non breaking space?

          Comment

          Working...