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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts

    Stop Firefox from Reading This

    Code:
    function loadMenu_FadeIn(){
    	menuOpacity += 10;
    	document.getElementById('MenuDiv').style.filter = "alpha(opacity: "+menuOpacity+")";
    	
    	if( menuOpacity<100 ){
    		setTimeout('loadMenu_FadeIn()', 50);
    	}
    }
    This filter fade will only work in IE. So unless someone knows of a way to do this in FF, how can I make FF ignore this code? (That way it dosn't spit junk into the Javascript Consol)

    Thanks guys.
    If I'm postin here, I NEED YOUR HELP!!

  • #2
    Senior Coder
    Join Date
    Dec 2004
    Location
    Essex, UK
    Posts
    2,636
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Mozilla uses -moz-opacity for opacity, so really you should be detecting IE and Firefox, and then every other browser (using 'opacity'), and provide each one with the correct function.

    http://www.mozilla.org/docs/web-deve...wser_type.html

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    Oregon, United States of America
    Posts
    882
    Thanks
    1
    Thanked 9 Times in 9 Posts
    The page you linked to states at the top that it is out of date, and not use it.
    Also, the functions listed on it error on all browsers.
    If I'm postin here, I NEED YOUR HELP!!

  • #4
    Regular Coder
    Join Date
    Sep 2005
    Posts
    535
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This site has a good review of the current opacity attributes that different browsers use. There are two ways to actually test which to use. The first would be to test the existance of each property before attempting to change it:
    Code:
    if(object.style.opacity)
    { 
      object.style.opacity=opacityStrength / 100;
    } else {
      if(object.style.filter)
      {
        object.style.filter = "alpha(opacity:"+ opacityStrength+")";
      }
    }
    The other way is just to assign each without testing before. You'd basically cause each object to be a little bigger since it would hold a property for each browser, but only the browser-specific attribute would actually be used when displaying the page (this is the procedure that the link used).

    One last thing to note: IE's opacity strength is 100 times the values used by the other browsers. Basically IE used percentage (eg 0% to 100%) whereas the other browsers used a value between 0 and 1.
    If you want answers, write a smart question.

    Yes, someone probably does know how...

    Oh, and if you want to learn, STFW!


  •  

    Posting Permissions

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