opacity

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
sorin21us
Forum Newbie
Posts: 9
Joined: Mon Feb 11, 2008 9:25 am

opacity

Post by sorin21us »

I know that this forum is for PHP, but maybe someone knows how to make in java script the code for an image opacity. I want that because if I put the opacity with css
#image
{
opacity: 0.30;
}

doesn't work in IE and Firefox, and I know that you can do that with java script, but I don't know how.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: opacity

Post by onion2k »

There's a lot of CSS 3 things that browsers can't do. I imagine opacity is one of them.
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Re: opacity

Post by Zoxive »

Opacity is Actually CSS2.

http://www.quirksmode.org/css/opacity.html

http://www.mandarindesign.com/opacity.html

Code: Select all

<div id="test"></div>
<style type="text/css">
    #test{
        background-color:red;
        width:100px;
        height:100px;
        opacity:.30;
    }
</style>
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: opacity

Post by pickle »

sorin21us wrote:I know that this forum is for PHP
That's why we have a Client-Side forum. I'm moving the thread there.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
sorin21us
Forum Newbie
Posts: 9
Joined: Mon Feb 11, 2008 9:25 am

Re: opacity

Post by sorin21us »

Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Thank you for the answers.

I was looking for something like this:

/*--- The code in js for opacity to works with filter IE and with opacity Firefox----*/

Code: Select all

function setOpacity(value) {
    document.getElementById("mage").style.opacity = value/10;
    document.getElementById("image").style.filter = 'alpha(opacity=' + value*10 + ')';
}
/*--The oapacity with CSS2 works only for Firefox---*/

Code: Select all

 
image
{
 opacity: 0.30;
 
}

Mod | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: opacity

Post by pickle »

IE doesn't support standards-based opacity (or at least IE6 didn't). You'll need to play around with the filter property. Google likely has something to say about the subject too.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply