Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    change color of transparency gif

    can I change color of transparency mono-color gif on client-side (javascript)?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    As I said on another forum. JavaScript has no image capabilities. Look into CSS opacity and background color.

    Eric
    Tech Author [Ajax In Action, JavaScript: Visual Blueprint]

  • #3
    Senior Coder rangana's Avatar
    Join Date
    Feb 2008
    Location
    Cebu City, Philippines
    Posts
    1,752
    Thanks
    65
    Thanked 372 Times in 365 Posts
    Yes, as what A1ien51 said, opacity could work this for you.
    ...and JS could always access CSS:
    Code:
    obj.style.filter = 'alpha(opacity=50)'; 
    obj.style.opacity='0.5';
    See if this basic example helps
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" 
       "http://www.w3.org/TR/html4/strict.dtd"> 
    <html> 
    <head> 
    <title></title> 
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
    
    <style type="text/css"> 
    img{ 
    filter:alpha(opacity=50); 
    opacity:.50; 
    text-align:center;margin:auto;} 
    #wrap{width:500px;margin:20px auto;border:3px double #aaa;text-align:center;padding:5px;} 
    </style> 
    <script type="text/javascript"> 
    var iterate=1,fiterate=0.1,test; 
    function rangfunc() 
    { 
       var obj=document.getElementById('myimage'); 
       obj.style.filter = 'alpha(opacity='+iterate+')'; 
       obj.style.opacity=fiterate; 
       iterate+=2; 
       fiterate+=0.02; 
    test=setTimeout('rangfunc()',50); 
    } 
    window.onload = function() 
    { 
    var obj=document.getElementById('myimage'); 
    obj.style.filter = 'alpha(opacity=1)'; 
    obj.style.opacity='0.1'; 
    rangfunc(); 
    } 
    </script> 
    </head> 
    <body> 
    <div id="wrap"> 
    <img src="http://www.hickerphoto.com/data/media/186/nice-provence-france_12218.jpg" alt="myimage" id="myimage"/> 
    </div> 
    </body> 
    </html>
    Learn how to javascript at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph


  •  

    Posting Permissions

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