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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post

    Having trouble with styles and mozilla

    How do I use a style to change the opacity of an image with the document.getElementById method? All help is appreciated.
    I would rather be a lion for a day than a lamb that lives forever.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    For Mozilla it is something like

    document.getElementById(id).style.MozOpacity=value
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    I currently have this for mozilla

    document.getElementById("image3").style="-moz-opacity: 70%";

    and

    document.images["image3"].style="filter: alpha(opacity=50)";

    for internet explorer. These keep throwing errors. I thought the IE way worked until I checked it again. Has anyone done anything like this? all help is appreciated.
    I would rather be a lion for a day than a lamb that lives forever.

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    70
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wrong syntax. As Mr. J illustrated, you have to reference the style property in the dot syntax. Not like you do in CSS.

    document.getElementById("problem").style.display = "block"; is valid

    document.getElementById("problem").style = display: block; is not

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    How could I have missed that, thanks fellas.
    I would rather be a lion for a day than a lamb that lives forever.


  •  

    Posting Permissions

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