made by 8 Dimensions ©
This JavaScript mini library purpose is provide a simple interface for transparency supporting browsers. The provided functions allow gradual fade-in, fade-out and consistent setting of transparency of any visual object defined on a webpage. They can be easily used in any JavaScript code.
Other variables are defined in the library. Their usage outside the library is not advised tough as it my compromise the correct behavior of the functions.
Paremeters:
none
This function must be called in the <BODY> section of the page before any of the other functions are used. Its purpose is to identify browser transparency support. It's recommended to call the function immediately after the <BODY> tag. The only legit way to omit this function and allow the library to work correctly is to call the identifyTransparencyOnObject function instead.
For identification purposes a hidden <SAN> object is created, that should not interfere anyhow with any other objects on the page.
Paremeters:
This function can be called instead of identifyTransparency function to detect transparency support of the user's browser. Similarly as the above mentioned function it must be called before any other transparency function (or the transparencySupported variable) is used but after the object it should be used on was defined.
It's advantage is no hidden <SPAN> object is created. On the other hand the object passed in has to have some special attributes. The object has to have the following inline style specification:
style="filter:progid:DXImageTransform.Microsoft.alpha(opacity=100);opacity:1;-moz-opacity:1;-khtml-opacity:1;"
The style has to be defined in the style attribute of the object, not by standard style either internal in the html file nor external (for some strange reason some browsers then fail to return transparency style correctly).
This function makes the visual object on the web to fade-in during the time specified in the second parameter. The process start by setting the opacity of the object to the initial value and then gradually becoming more and more opaque. Finally the object is 100% opaque and the function passed as the third parameter is called (if this was specified). The function is provided with one parameter - the object, that was fading-in.
This function is almost identical to fadeIn only that the object instead of gradually appearing gradually disappears.
In this case a good example of the finishing function is to set the object style to 'none' avoiding the possibility to select it (strange to select an invisible object):
<SCRIPT language="JavaScript" type="text/javascript">
function fadeOutFinished(in_Obj) {
in_Obj.style.display = 'none';
}
</SCRIPT>
Paremeters:
This function directly changes the opacity of a visual object on the page. In case transparency is not supported in the browser setting an object's opacity to 0 makes it invisible, while setting it to anything greater then 0 makes it fully visible. As both fadeIn and fadeOut functions use this function, hence the limited functionality in transparency not supporting browsers - instead of gradually appearing or disappearing the simply pop-in or out.
There are other functions in the library with names starting with “_”. They are not intended to be called from outside the library.
Example:
...
<script type="text/javascript" LANGUAGE="JavaScript" SRC="../scripts/Dim8_transparency_v1_0.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function objectFadedOut(in_Obj){
fadeIn(in_Obj,5000);
}
//-->
</script>
</head>
<body onload="javascript:fadeOut(document.getElementById('MyDiv'),10000,objectFadedOut,0.9)">
<script language="JavaScript" type="text/javascript">
<!--
identifyTransparency();
//-->
</script>
<div id="MyDiv">Hello world</div>
...
Alternatively
Example:
<script type="text/javascript" LANGUAGE="JavaScript" SRC="../scripts/Dim8_transparency_v1_0.js"></script>
</head>
<body onload="javascript:setOpacity(document.getElementById('MyTab'),0.5)">
<table summary="" border="=1" id="MyTab" style="filter:progid:DXImageTransform.Microsoft.alpha(opacity=100);opacity:1;-moz-opacity:1;-khtml-opacity:1;">
<tr>
<td> </td>
</tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
identifyTransparencyOnObject(document.getElementById("MyTab"));
//-->
</script>
...
(no cross fade, no partial transparency only visible/invisible)
The compatibility with other browsers depend whether they support DOM and opacity.
1.0 | 12.II.2007 | The first version released |
The library was created by 8 Dimensions. Go to www.8dimensions.com to see more.