Hi, I can change the lement opacity in IE using.
abc.style.filter = 'alpha(opacity=' + 10 + ')';
But this dont work in firefox, In firefox it throws error.
How I can change the opacity of an element in Firefox.
Hi,
only IE understands filter effects like filter:alpha(opacity=10),
therefore Firefox will throw an error, if you tyr to use them.
I would define a cross browser opacity style definition, like
Code:
/* works but is not valid css */
.opacity { filter:alpha(opacity=10); -moz-opacity:0.1; opacity:0.1; }
and would only replace the className property using JavaScript
Code:
abc.className = "opacity";
Regards,
purcaholic
Hi,
I tried using a class. But to no avail.
That's what I did.
In my style sheet I defined a class.
.style3 {
opacity: 0.9999;
-moz-opacity: 0.9999;
-khtml-opacity: 0.9999;}
and then I applied that class to the object
element.style3 = ".44";
Is that, What I did is correct or wrong?- Zitierten Text ausblenden-
- Zitierten Text anzeigen -
Try to set the classname using
Code:
element.className = "style3";
If you need several nuances of opacity, then you have to use
javascript, following code should do the trick:
Code:
var oStyle = document.getElementById(id).style;
oStyle.opacity = (opacity / 100);
if (typeof(oStyle.MozOpacity) === "string") {
oStyle.MozOpacity = (opacity / 100);} else if (typeof(oStyle.KhtmlOpacity) === "string") {
oStyle.KhtmlOpacity = (opacity / 100);} else if (typeof(oStyle.filter) === "string") {
oStyle.filter = "alpha(opacity=" + opacity + ")";}
Regards,
purcaholic- Hide quoted text -
- Show quoted text -