Forum Moderators: open
<div id="divToHide">
to show this content <br />
<a onclick="hideDiv()" style="cursor:pointer;">close</a>
</div>
[/codes]
here the divToHide is the one hidden and who should bear the blur effect
To adjust the transparency level of the div, you adjust two different values. First, you adjust opacity for standards compliant browsers, then you add an alpha(opacity) filter for IE.
var element = document.getElementById(el_id);
element.style.opacity = .5;
element.style.filter = 'alpha(opacity = ' + 50 + ')';
To animate, you can use setTimeout to call a function in a tight loop that decrements the opacity value each time it runs.
var opacity=0;
var=t;
var div_is_visible=0;
function optionsEffect() {
document.getElementById('div-to-show').style.opacity=opacity;
document.getElementById('div-to-show').style.filter = 'alpha(opacity = ' + opacity + ')'; //IE stuff
o=o+1; // it increases the opacity by 1
t=setTimeout("optionsEffect()",10); // this line makes a loop every 100th of a second
}
function showOptions () { // this function checks if the div is not already visible and hence stops repetitions
if (!div_is_visible) {
div_is_visible=1;
optionsEffect();
}
}
<div onclick="showOptions">Click here to show the hidden div</div>
And @ Fotiman Sorry.. i actually meant JavaScript only. I will take care of this from now.. :)
<script type="text/javascript">
var opacity=0;
var t;
function optionsEffect()
{
if(opacity<101) {
document.getElementById('options-content').style.opacity=opacity/100;
document.getElementById('options-content').style.filter = "alpha(opacity=" + opacity + ")";
opacity=opacity+1;
t=setTimeout("optionsEffect()",10);
}
}function optionsEffectReverse()
{
if(opacity>0) {
document.getElementById('options-content').style.opacity=opacity/100;
document.getElementById('options-content').style.filter = "alpha(opacity=" + opacity + ")";
opacity=opacity-1;
t=setTimeout("optionsEffectReverse()",10);
}
}
function showOptions() {
document.getElementById('more-options').href = "../css/options.css";
optionsEffect();
}
function confirmHideOptions() {
document.getElementById('more-options').href = "";
}
function hideOptions() {
optionsEffectReverse();
confirmHideOptions();
}
</script>
May be all i needed was some idea... i did it well.. if anybody intrested, it can be ssen working here when you click the small options logo. it dosent work in Ie though... but it should work... Does anybody know why it doesn't?
<snipped url>
[edited by: whoisgregg at 5:02 pm (utc) on Nov. 29, 2009]
[edit reason] Whoops, no URLs please. See TOS [webmasterworld.com] :) [/edit]