I have been trying fo two days to get this script to work in firefox, looking at other simmiler scripts that work in firefox but still can't find the answer to why it's not working, I think I've add 50% more code them what I started with and still nothing.
Can anyone point me in the direction to where the problem is in this script?
code:
<script language="JavaScript" type="text/javascript">
var ns6=document.getElementById&&!document.all;
var vmin=5;
var vmax=5;
var vr=2;
var timer1;
function Chip (chipname, width, height)
{
this.named = chipname;
this.vx = vmin+vmax*Math.random();
this.vy = vmin+vmax*Math.random();
this.w = width;
this.h = height;
this.xx = 0;
this.yy = 0;
this.timer1 = null;
}
function movechip (chipname)
{
eval( 'chip=' + chipname);
if(!getRefToDivNest(chipname)) { return; }
var scrWidth = 0, scrHeight = 0, scrollHeight = 0, scrollWidth = 0;
//find screen settings for all variations. doing this every time allows for resizing and scrolling
if(typeof(window.innerWidth) == 'number')
{
scrWidth = window.innerWidth-10;
scrHeight = window.innerHeight-10;
}
else
{
if(document.documentElement && (document.documentElement.clientWidth | | document.documentElement.clientHeight))
{
scrWidth = document.documentElement.clientWidth-10;
scrHeight = document.documentElement.clientHeight-10;
}
else
{
if(document.body && (document.body.clientWidth | | document.body.clientHeight))
{
scrWidth = document.body.clientWidth-10;
scrHeight = document.body.clientHeight-10;
}
}
}
if(typeof(window.pageYOffset) == 'number')
{
scrollHeight = pageYOffset;
scrollWidth = pageXOffset;
}
else
{
if(document.body && (document.body.scrollLeft | | document.body.scrollTop))
{
scrollHeight = document.body.scrollTop;
scrollWidth = document.body.scrollLeft;
}
else
{
if(document.documentElement && (document.documentElement.scrollLeft | | document.documentElement.scrollTop))
{
scrollHeight = document.documentElement.scrollTop;
scrollWidth = document.documentElement.scrollLeft;
}
}
}
chip.xx = chip.xx+chip.vx;
chip.yy = chip.yy+chip.vy;
chip.vx += vr*(Math.random()-0.5);
chip.vy += vr*(Math.random()-0.5);
if (chip.vx > (vmax+vmin)) chip.vx = (vmax+vmin)*2-chip.vx;
if (chip.vx < (-vmax-vmin)) chip.vx = (-vmax-vmin)*2-chip.vx;
if (chip.vy > (vmax+vmin)) chip.vy = (vmax+vmin)*2-chip.vy;
if (chip.vy < (-vmax-vmin)) chip.vy = (-vmax-vmin)*2-chip.vy;
if (chip.xx <= scrollWidth)
{
chip.xx =scrollWidth;
chip.vx =vmin+vmax*Math.random();
}
if (chip.xx >= scrollWidth+scrWidth-chip.w)
{
chip.xx =scrollWidth+scrWidth-chip.w;
chip.vx =-vmin-vmax*Math.random();
}
if (chip.yy <= scrollHeight)
{
chip.yy =scrollHeight;
chip.vy =vmin+vmax*Math.random();
}
if (chip.yy >= scrollHeight+scrHeight-chip.h)
{
chip.yy =scrollHeight+scrHeight-chip.h;
chip.vy =-vmin-vmax*Math.random();
}
if (document.layers)
{
eval( 'document.chip1.top =' + chip.yy);
eval( 'document.chip1.left=' + chip.xx);
}
else if (document.all)
{
eval( 'document.all.chip1.style.pixelLeft=' + chip.xx);
eval( 'document.all.chip1.style.pixelTop =' + chip.yy);
}
else if (ns6)
{
eval( 'document.getElementById(chip1).style.left=' + chip.xx);
eval( 'document.getElementById(chip1).style.top =' + chip.yy);
}
chip.timer1 = setTimeout("movechip('" + chip.named + "')", 25);
}
function stopme (chipname)
{
eval( 'chip=' + chipname);
if (chip.timer1!=null)
{
clearTimeout(chip.timer1)
}
}
//DHTML handlers
function getRefToDivNest(divName) {
if( document.layers ) { return document.layers[divName]; } //NS4
if( document[divName] ) { return document[divName]; } //NS4 also
if( document.getElementById ) { return document.getElementById(divName); } //DOM (IE5+, NS6+, Mozilla0.9+, Opera)
if( document.all ) { return document.all[divName]; } //Proprietary DOM - IE4
return false;
}
</script>
<script language="JavaScript" type="text/javascript">
/*
Floating image script
By Virtual_Max (http://www.geocities.com/siliconvalley/lakes/8620)
Permission granted to Dynamicdrive.com to feature it in it's archive
For 100's of FREE DHTML scripts and components,
Visit [url=http://dynamicdrive.com]http://dynamicdrive.com[/url]
*/
var chip1;
//add or delete more variables, depending on how many images you're using
function pagestart()
{
chip1=new Chip("chip1",60,80);
chip1.xx = 234;
chip1.yy = 423;
//add or delete more of the above, depending on how many images you're using
if(document.layers| |document.all| |(document.getElementById && !document.all))
{
movechip("chip1");
//add or delete more of the above, depending on how many images you're using
}
}
</script>
<script language="JavaScript" type="text/javascript">
var html ='';
var llama = '<a href="index.php?action=magicLlama;magicLlama=MD5_STRING">';
llama += '<img name="Llama" src="./golden_llama2.gif" border=0></a>';
if (document.layers)
{
html += '<layer id="chip1" name="chip1" style="position: absolute; top: 423; left: 234; width: 68; height: 68; z-index: 5">';
html += llama;
html += '</layer>';
document.write(html);
}
else
{
html += '<div id="chip1" name="chip1" style="position: absolute; top: 423; left: 234; width: 68; height: 68; z-index: 5">';
html += llama;
html += '</div>';
document.write(html);
}
pagestart();
window.onUnload = "stopme('chip1');";
</script>
Thanks a million for any help, tips!
Aquilo
<A HREF="http://x-design.atari.org
" TARGET=_blank> <img border=0 src="http://xtram.hypermart.net/downloads/aquilo_ozone.gif[/IMG]</A>
[img]">