www.webdeveloper.com
Results 1 to 2 of 2

Thread: making text appear after javascript function has run

Hybrid View

  1. #1
    Join Date
    Mar 2010
    Posts
    1

    making text appear after javascript function has run

    I followed the tutorial below and got my image fade to work:
    http://clagnut.com/sandbox/imagefades/

    Now I want to have text become visible once the fade is done. I can't get it to work.

    style portion:

    .enhanced {
    visibility:hidden;
    }

    javascript functions:

    <script language="javascript">
    document.write("<style type='text/css'> ##thephoto {visibility:hidden;} </style>");
    window.onload = function() {initImage()};
    function initImage() {
    imageId = 'thephoto';
    image = document.getElementById(imageId);
    setOpacity(image, 0);
    image.style.visibility = 'visible';
    fadeIn(imageId,0);
    }
    function setOpacity(obj, opacity) {
    opacity = (opacity == 100)?99.999pacity;

    // IE/Win
    obj.style.filter = "alpha(opacity:"+opacity+")";

    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity = opacity/100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity = opacity/100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity = opacity/100;
    }
    function fadeIn(objId,opacity) {
    if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
    setOpacity(obj, opacity);
    opacity += 10;
    window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 150);
    }
    if (opacity = 100) {
    textId = 'enhanced';
    text = document.getElementById(textId);
    text.style.visibility="visible";
    }
    }
    }
    </script>

    I have added this to the last function:

    if (opacity = 100) {
    textId = 'enhanced';
    text = document.getElementById(textId);
    text.style.visibility="visible";
    }

    But the text appears instantly.

  2. #2
    Join Date
    Dec 2009
    Posts
    24
    it shouldn't be
    if(opacity = 100), that is actually setting the opacity to 100,
    instead, put

    if(opacity == 100)

    this should work

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles