L
lindmark.daniel
Since I'm a mac-head, I don't have the possibility to make this little
script I wrote work proper on a MSIE browser.
I know there's smarts in here that easily could spot my f**k ups and
tell me what I'm doing wrong.
Code works just fine on Firefox 1.5, Safari 2.0 and Opera (with some
minor buggs)
On explorer, as far as I know, it just produce page errors with cryptic
error messages.
Can anybody help me?
The script
[THE CODE]
function visaLager(id,width,height,speed,opacityTar)
{
// fakey speed convert to ensure int value
var speeda = speed*1
// fetch layer
var el = document.getElementById(id);
// get current size of layer
var h_size1 = el.offsetHeight;
var v_size1 = el.offsetWidth;
// get size of screen
if (self.innerWidth)
{
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}
else if (document.documentElement &&
document.documentElement.clientWidth)
{
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}
var widthStepper = Math.round((width/100) *speeda);
var heightStepper = Math.round((height/100) *speeda);
// the loop the loop
if (h_size1 < width || v_size1 < height)
{
//centers the layer
var topPos = ((frameHeight/2) - (h_size1/2)) + window.pageYOffset;
var leftPos = ((frameWidth/2) - (v_size1/2));
// ensures us that the layer doesnt cover the cats
if(topPos< 200) { topPos = 210; }
// and here we place the layer
el.style.top = topPos + "px";
el.style.left = leftPos + "px";
if(h_size1 < height)
{
// updates the height of the layer
el.style.height = (h_size1 + heightStepper) +"px";
}
if(v_size1 < width)
{
// updates the width of the layer
el.style.width = (v_size1 + widthStepper) +"px";
}
//dont animate opacity in Explorer, just set it
if(!navigator.appName.match("Microsoft"))
{
if(el.style.opacity < (opacityTar/100))
{
var opacity = ((el.style.opacity*10) + 1)/10
el.style.opacity=opacity
}
}else{
el.style.filter="alpha(opacity="+opacityTar+")";
}
// defines a timeout to get that sweet animated effect
r = setTimeout("visaLager('" + id + "','" + width + "','" + height +
"', '" + speed +"','" + opacityTar + "')", 1);
}else{
// clear the timeout when target size is set
clearTimeout(r)
}
}
[/CODE]
script I wrote work proper on a MSIE browser.
I know there's smarts in here that easily could spot my f**k ups and
tell me what I'm doing wrong.
Code works just fine on Firefox 1.5, Safari 2.0 and Opera (with some
minor buggs)
On explorer, as far as I know, it just produce page errors with cryptic
error messages.
Can anybody help me?
The script
[THE CODE]
function visaLager(id,width,height,speed,opacityTar)
{
// fakey speed convert to ensure int value
var speeda = speed*1
// fetch layer
var el = document.getElementById(id);
// get current size of layer
var h_size1 = el.offsetHeight;
var v_size1 = el.offsetWidth;
// get size of screen
if (self.innerWidth)
{
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}
else if (document.documentElement &&
document.documentElement.clientWidth)
{
frameWidth = document.documentElement.clientWidth;
frameHeight = document.documentElement.clientHeight;
}
else if (document.body)
{
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}
var widthStepper = Math.round((width/100) *speeda);
var heightStepper = Math.round((height/100) *speeda);
// the loop the loop
if (h_size1 < width || v_size1 < height)
{
//centers the layer
var topPos = ((frameHeight/2) - (h_size1/2)) + window.pageYOffset;
var leftPos = ((frameWidth/2) - (v_size1/2));
// ensures us that the layer doesnt cover the cats
if(topPos< 200) { topPos = 210; }
// and here we place the layer
el.style.top = topPos + "px";
el.style.left = leftPos + "px";
if(h_size1 < height)
{
// updates the height of the layer
el.style.height = (h_size1 + heightStepper) +"px";
}
if(v_size1 < width)
{
// updates the width of the layer
el.style.width = (v_size1 + widthStepper) +"px";
}
//dont animate opacity in Explorer, just set it
if(!navigator.appName.match("Microsoft"))
{
if(el.style.opacity < (opacityTar/100))
{
var opacity = ((el.style.opacity*10) + 1)/10
el.style.opacity=opacity
}
}else{
el.style.filter="alpha(opacity="+opacityTar+")";
}
// defines a timeout to get that sweet animated effect
r = setTimeout("visaLager('" + id + "','" + width + "','" + height +
"', '" + speed +"','" + opacityTar + "')", 1);
}else{
// clear the timeout when target size is set
clearTimeout(r)
}
}
[/CODE]