Jump to content
  • 0

Смена прозрачности


Павел
 Share

Question

Здравствуйте!

Прошу помощи :)

есть код

<style>
div.block {
padding: 4px;
background: #f00;
}
</style>
<script>
var Opacity =
{
set: function(elem, op)
{
var prop = this.getProperty();
if (!elem || !prop)
return false;

if (prop == 'filter')
{
op *= 100;
var oAlpha = elem.filters['DXImageTransform.Microsoft.alpha'] || elem.filters.alpha;
if (oAlpha)
oAlpha.opacity = op;
else
elem.style.filter += 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + op + ')';
}
else
elem.style[prop] = op;
},
getProperty: function()
{
if (typeof document.body.style.opacity == 'string')
return 'opacity';
else if (typeof document.body.style.MozOpacity == 'string')
return 'MozOpacity';
else if (typeof document.body.style.KhtmlOpacity == 'string')
return 'KhtmlOpacity';
else if (document.body.filters && navigator.appVersion.match(/MSIE ([d.]+);/)[1]>=5.5)
return 'filter';
return '';
}
};
</script>

<div class="block" onclick="Opacity.set(this, 0.3)">Text</div>

этот код не работает в IE6/IE7 и отлично работает в FF, Opera, Safari.

Не пойму что происходит..

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

filter Attribute | filter Property:

An object must have layout for the filter to render. A simple way to accomplish this is to give the element a specified height and/or width. However, there are several other properties that can give an element layout. For more information on these other properties, see the hasLayout property.

hasLayout Property:

display inline-block

height any value

float left or right

position absolute

width any value

writing-mode tb-rl

zoom any value

Link to comment
Share on other sites

  • 0
filter Attribute | filter Property:
An object must have layout for the filter to render. A simple way to accomplish this is to give the element a specified height and/or width. However, there are several other properties that can give an element layout. For more information on these other properties, see the hasLayout property.

hasLayout Property:

display inline-block

height any value

float left or right

position absolute

width any value

writing-mode tb-rl

zoom any value

Помогло!

Огромное спасибо!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy