Forum Moderators: open
here's my code:
[b]//this bit goes before the content for the scroller[/b]
var speed=8;newschool=document.all¦¦document.getElementById
document.write('<div id="mscrollercontain" style="position:relative;height:518px;width:416px;overflow:hidden;">')
document.write('<div id="mscrollercontent" style="position:absolute;left:0px;top:0px;padding:10px;">')
[b]//this bit goes after[/b]
document.write('</div></div>')
var crossobj=document.getElementById? document.getElementById("mscrollercontent") : document.all.content
var contentheight=crossobj.offsetHeight
function movedown(){
if (window.moveupvar) clearTimeout(moveupvar)
if (newschool&&parseInt(crossobj.style.top)>=(contentheight*(-1)+300))
crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
else if (crossobj.top>=(contentheight*(-1)+50))
crossobj.top-=speed
movedownvar=setTimeout("movedown()",20)
}
function moveup(){
if(crossobj.style.top!=0+"px")
{
if (window.movedownvar) clearTimeout(movedownvar);
if (newschool&&parseInt(crossobj.style.top)<=0);
crossobj.style.top=parseInt(crossobj.style.top)+speed+"px";
moveupvar=setTimeout("moveup()",20);
}
}
function stopscroll(){
if (window.moveupvar) clearTimeout(moveupvar);
if (window.movedownvar) clearTimeout(movedownvar);
}
function movetop(){
stopscroll()
crossobj.style.top=0+"px"
}
function getcontent_height(){
contentheight=crossobj.offsetHeight
}
[b]//this bit is the ie behavior for png transparency[/b]
<public:component>
<public:attach event="onpropertychange" onevent="propertyChanged()" />
<script>
var supported = /MSIE (5\.5)¦[6789]/.test(navigator.userAgent) && navigator.platform == "Win32";
var realSrc;
var blankSrc = "/assets/shoppingcart-images/spacer.gif";
if (supported) fixImage();
function propertyChanged() {
if (!supported) return;
var pName = event.propertyName;
if (pName!= "src") return;
// if not set to blank
if (! new RegExp(blankSrc).test(src))
fixImage();
};
function fixImage() {
// get src
var src = element.src;
// check for real change
if (src == realSrc) {
element.src = blankSrc;
return;
}
if (! new RegExp(blankSrc).test(src)) {
// backup old src
realSrc = src;
}
// test for png
if ( /\.png$/.test( realSrc.toLowerCase() ) ) {
// set blank image
element.src = blankSrc;
// set filter
element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
src + "',sizingMethod='scale')";
}
else {
// remove filter
element.runtimeStyle.filter = "";
}
}
</script>
</public:component>
Personally, I use the koivi.com PHP script [koivi.com] to handle alpha transparent PNGs. I have no association with koivi.com, it's just the best way I've found so far.