Reply
Javascript works in ie but not in firefox
Old 11-17-2008, 04:02 PM Javascript works in ie but not in firefox
Junior Talker

Posts: 4
Name: bill Libecap
Hi
First of all I am new here so please understand that.
I have located 2 Javascripts that I would like to combine or fix the first one.
I am not able to contact the author of these scripts.

I have a small image that I would like to move across the bottom of the screen and have bubbles come out of it. Ideally the bubbles would expand on rising, come out in groups with time in between groups. The script that I have has very little variable documentation and I am at a bit of a loss.

I am not a java script programmer but I do have a programing backgrown.

I will list the script i would like to modify below and the second script in the next message in this thread.

again

THANKS

Bill

<script language="JavaScript">
<!-- Net Pet - Original http://www.btinternet.com/~kurt.grigg/javascript -->
<!-- Distributed by http://www.hypergurl.com -->
how_many_bubbles=5;
pics=new Array();
load=new Array();
for(i=0;
i <= 6;
i++){ pics[i]=i+".gif";
} for(i=0;
i < pics.length;
i++){ load[i]=new Image();
load[i].src=pics[i];
} bub_image=new Image();
bub_image.src="bubble.gif";
ns=(document.layers)?1:0;
strt=0-(load[0].width+50);
ypos=new Array();
xpos=new Array();
speed=new Array();
rate=new Array();
grow=new Array();
step=new Array();
cstep=new Array();
ns_size=new Array();
pos=-1;
jog=1;
timer=null;
sd=0;
h=0;
w=0;
sy=0;
sx=0;
inih=(ns)?window.innerHeight:window.document.body. clientHeight;
for (i=0;
i < how_many_bubbles;
i++){ ypos[i]=Math.random()*inih-50;
xpos[i]=-50;
speed[i]=Math.random()*10+1;
cstep[i]=0;
step[i]=Math.random()*0.1+0.05;
grow[i]=4;
ns_size[i]=Math.random()*4+6;
rate[i]=Math.random()*0.5+0.1;
} if (ns){ for (i=0;
i < how_many_bubbles;
i++){ document.write("<layer name='bubs"+i+"' left=0 top=-50>" +"<img src="+bub_image.src+" width="+ns_size[i]+" height="+ns_size[i]+"></layer>");
} document.write("<layer name='fish' left=0 top=-50><img src='0.gif' name='frame'></layer>");
} else{ document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i=0;
i < how_many_bubbles;
i++){ document.write('<img id="bubs'+i+'" src="'+bub_image.src+'" style="position:absolute;top:-50px;left:0px">');
} document.write('</div></div>');
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">' +'<img id="fish" src="0.gif" name="frame" style="position:absolute;top:-100px;left:0px"></div></div>');
} function AniFish(){ pos+=jog;
if (pos >= pics.length) pos=0;
if (ns) document.fish.document.images.frame.src=pics[pos];
else document.images.frame.src=pics[pos];
} function MoveFish(){ h=(ns)?window.innerHeight:window.document.body.cli entHeight;
w=(ns)?window.innerWidth:window.document.body.clie ntWidth;
sy=(ns)?window.pageYOffset:document.body.scrollTop ;
sx=(ns)?window.pageXOffset:document.body.scrollLef t;
strt-=2;
sd=h-(load[0].height+10);
if (strt < 0-(load[0].width)) strt=w;
if (ns){ document.fish.left=strt+sx;
document.fish.top=sd+sy;
} else{ fish.style.left=strt+sx;
fish.style.top=sd+sy;
} AniFish();
setTimeout('MoveFish()',50) } function Bubbles(){ for (i=0;
i < how_many_bubbles;
i++){ dy = speed[i]*Math.sin(270*Math.PI/180);
dx = speed[i]*Math.cos(cstep[i]*5);
ypos[i]+=dy;
xpos[i]+=dx;
ey=sd;
ex=strt;
if (ypos[i] < -40){ ypos[i]=ey;
xpos[i]=ex;
speed[i]= 6+Math.random()*3;
grow[i]=4;
ns_size[i]=Math.random()*4+6;
} if (ns){ document.layers['bubs'+i].top=ypos[i]+sy;
document.layers['bubs'+i].left=xpos[i]+sx;
} else{ document.all['bubs'+i].style.top=ypos[i]+sy;
document.all['bubs'+i].style.left=xpos[i]+sx;
document.all['bubs'+i].style.width=grow[i];
document.all['bubs'+i].style.height=grow[i];
} grow[i]+=rate[i];
cstep[i]+=step[i];
if (grow[i] > 15) grow[i]=16;
} setTimeout('Bubbles()',10);
} function Start(){ MoveFish();
Bubbles();
} if (document.all||ns){ setTimeout('Start()',2000);
} //--> </script>


Thanks again Bill
blibecap is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-17-2008, 04:04 PM Re: Javascript works in ie but not in firefox
Junior Talker

Posts: 4
Name: bill Libecap
Here is the second similar script that works but is attached to the mouse not the moving image.

by the way the only missing items are a couple of bubble.gif files.

<script language="JavaScript">

<!-- Begin
/* This script was originally written by Kurt Grigg (kurt.grigg@virgin.net)
Web Site: http://website.lineone.net/~kurt.grigg/javascript
and was modified by N8i (www.nightfire.ch) in April 2005
The script works now with NS4, IE4+, NS6+, Mozilla, Firefox, ...
*/

//Browser Sniffer
var ns4up = (document.layers) ? 1 : 0;
var ie4up = (document.all) ? 1 : 0;
var mozup = (!document.all && document.getElementById) ? 1 : 0;

Image0 = new Image();
Image0.src = "bubble.gif";
Amount = 10;
Ymouse = -50;
Xmouse = -50;
Ypos = new Array();
Xpos = new Array();
Speed = new Array();
rate = new Array();
grow = new Array();
Step = new Array();
Cstep = new Array();
nsSize = new Array();

// Capturing MouseMove
function handlerMM(e) {
Xmouse = (ns4up || mozup) ? e.pageX : event.clientX
Ymouse = (ns4up || mozup) ? e.pageY-20 : event.clientY-20
}

if (ns4up) window.captureEvents(Event.MOUSEMOVE);
if (ns4up) window.onMouseMove = handlerMM
else document.onmousemove = handlerMM;

for (i = 0; i < Amount; i++) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random()*4+1;
Cstep[i] = 0;
Step[i] = Math.random()*0.1+0.05;
grow[i] = 8;
nsSize[i] = Math.random()*15+5;
rate[i] = Math.random()*0.5+0.1;
}

if (ns4up) {
for (i = 0; i < Amount; i++) {
document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0><img src="+Image0.src+" name='N' width="+nsSize[i]+" height="+nsSize[i]+"></LAYER>");
}
}
if (ie4up) {
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">');
for (i = 0; i < Amount; i++) {
document.write('<img id="si" src="'+Image0.src+'" style="position:absolute;top:0px;left:0px;filter:a lpha(opacity=90)">');
}
document.write('</div></div>');
}
if (mozup) {
for (i = 0; i < Amount; i++) {
document.write('<div id="si'+i+'" style="position:absolute;top:0px;left:0px">');
document.write('<img src="'+Image0.src+'" style="filter:-moz-opacity:0.9)">');
document.write('</div>');
}
}

function MouseBubbles() {
var hscrll = (ns4up || mozup)?window.pageYOffset:document.body.scrollTop;
var wscrll = (ns4up || mozup)?window.pageXOffset:document.body.scrollLeft ;
for (i = 0; i < Amount; i++){
sy = Speed[i] * Math.sin(270 * Math.PI / 180);
sx = Speed[i] * Math.cos(Cstep[i] * 4);
Ypos[i] += sy;
Xpos[i] += sx;
if (Ypos[i] < -40) {
Ypos[i] = Ymouse;
Xpos[i] = Xmouse;
Speed[i] = Math.random() * 6 + 4;
grow[i] = 8;
nsSize[i] = Math.random() * 15 + 5;
}
if (ns4up) {
document.layers['sn'+i].left = Xpos[i] + wscrll;
document.layers['sn'+i].top = Ypos[i] + hscrll;
}
if (ie4up) {
si[i].style.pixelLeft = Xpos[i] + wscrll;
si[i].style.pixelTop = Ypos[i] + hscrll;
si[i].style.width = grow[i];
si[i].style.height = grow[i];
}
if (mozup) {
document.getElementById("si"+i).style.left = Xpos[i] + wscrll;
document.getElementById("si"+i).style.top = Ypos[i] + hscrll;
document.getElementById("si"+i).firstChild.style.w idth = grow[i];
document.getElementById("si"+i).firstChild.style.h eight = grow[i];
}

grow[i] += rate[i];
Cstep[i] += Step[i];
if (grow[i] > 24) grow[i] = 25;
}
setTimeout('MouseBubbles()', 10);
}
MouseBubbles();
// End -->
</script>

http://www.nightfire.ch/java/index.h...les.htm~mypage
blibecap is offline
Reply With Quote
View Public Profile
 
Old 11-19-2008, 11:50 AM Re: Javascript works in ie but not in firefox
Junior Talker

Posts: 4
Name: bill Libecap
Well with no replies I wonder if I was supposed to put this in a code box? Maybe that will get me some answers. Anyone care to comment? I am new here.

Code:
<script language="JavaScript"> 
<!-- Net Pet - Original http://www.btinternet.com/~kurt.grigg/javascript --> 
<!-- Distributed by http://www.hypergurl.com -->
how_many_bubbles=5; 
pics=new Array(); 
load=new Array(); 
for(i=0; 
i <= 6; 
i++){ pics[i]=i+".gif"; 
} for(i=0; 
i < pics.length; 
i++){ load[i]=new Image(); 
load[i].src=pics[i]; 
} bub_image=new Image(); 
bub_image.src="bubble.gif"; 
ns=(document.layers)?1:0; 
strt=0-(load[0].width+50); 
ypos=new Array(); 
xpos=new Array(); 
speed=new Array(); 
rate=new Array(); 
grow=new Array(); 
step=new Array(); 
cstep=new Array(); 
ns_size=new Array(); 
pos=-1; 
jog=1; 
timer=null; 
sd=0; 
h=0; 
w=0; 
sy=0; 
sx=0; 
inih=(ns)?window.innerHeight:window.document.body.  clientHeight; 
for (i=0; 
i < how_many_bubbles; 
i++){ ypos[i]=Math.random()*inih-50; 
xpos[i]=-50; 
speed[i]=Math.random()*10+1; 
cstep[i]=0; 
step[i]=Math.random()*0.1+0.05; 
grow[i]=4; 
ns_size[i]=Math.random()*4+6; 
rate[i]=Math.random()*0.5+0.1; 
} if (ns){ for (i=0; 
i < how_many_bubbles; 
i++){ document.write("<layer name='bubs"+i+"' left=0 top=-50>" +"<img src="+bub_image.src+" width="+ns_size[i]+" height="+ns_size[i]+"></layer>"); 
} document.write("<layer name='fish' left=0 top=-50><img src='0.gif' name='frame'></layer>"); 
} else{ document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">'); 
for (i=0; 
i < how_many_bubbles; 
i++){ document.write('<img id="bubs'+i+'" src="'+bub_image.src+'" style="position:absolute;top:-50px;left:0px">'); 
} document.write('</div></div>'); 
document.write('<div style="position:absolute;top:0px;left:0px"><div style="position:relative">' +'<img id="fish" src="0.gif" name="frame" style="position:absolute;top:-100px;left:0px"></div></div>'); 
} function AniFish(){ pos+=jog; 
if (pos >= pics.length) pos=0; 
if (ns) document.fish.document.images.frame.src=pics[pos]; 
else document.images.frame.src=pics[pos]; 
} function MoveFish(){ h=(ns)?window.innerHeight:window.document.body.cli  entHeight; 
w=(ns)?window.innerWidth:window.document.body.clie  ntWidth; 
sy=(ns)?window.pageYOffset:document.body.scrollTop  ; 
sx=(ns)?window.pageXOffset:document.body.scrollLef  t; 
strt-=2; 
sd=h-(load[0].height+10); 
if (strt < 0-(load[0].width)) strt=w; 
if (ns){ document.fish.left=strt+sx; 
document.fish.top=sd+sy; 
} else{ fish.style.left=strt+sx; 
fish.style.top=sd+sy; 
} AniFish(); 
setTimeout('MoveFish()',50) } function Bubbles(){ for (i=0; 
i < how_many_bubbles; 
i++){ dy = speed[i]*Math.sin(270*Math.PI/180); 
dx = speed[i]*Math.cos(cstep[i]*5); 
ypos[i]+=dy; 
xpos[i]+=dx; 
ey=sd; 
ex=strt; 
if (ypos[i] < -40){ ypos[i]=ey; 
xpos[i]=ex; 
speed[i]= 6+Math.random()*3; 
grow[i]=4; 
ns_size[i]=Math.random()*4+6; 
} if (ns){ document.layers['bubs'+i].top=ypos[i]+sy; 
document.layers['bubs'+i].left=xpos[i]+sx; 
} else{ document.all['bubs'+i].style.top=ypos[i]+sy; 
document.all['bubs'+i].style.left=xpos[i]+sx; 
document.all['bubs'+i].style.width=grow[i]; 
document.all['bubs'+i].style.height=grow[i]; 
} grow[i]+=rate[i]; 
cstep[i]+=step[i]; 
if (grow[i] > 15) grow[i]=16; 
} setTimeout('Bubbles()',10); 
} function Start(){ MoveFish(); 
Bubbles(); 
} if (document.all||ns){ setTimeout('Start()',2000); 
} //--> </script>
Thanks
Bill
blibecap is offline
Reply With Quote
View Public Profile
 
Old 11-20-2008, 04:12 AM Re: Javascript works in ie but not in firefox
chrishirst's Avatar
Super Moderator

Posts: 19,022
Location: Blackpool. UK
the script on http://www.nightfire.ch/java/index.h...les.htm~mypage works perfectly well in FF, Seamonkey, Opera and IE

annoying but it works
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System | Bits & Bobs
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-20-2008, 10:55 AM Re: Javascript works in ie but not in firefox
Junior Talker

Posts: 4
Name: bill Libecap
Quote:
Originally Posted by chrishirst View Post
the script on http://www.nightfire.ch/java/index.html?jscript/js_mousebubbles.htm~mypage works perfectly well in FF, Seamonkey, Opera and IE

annoying but it works
Yes I know this works and my thought was to combine the two as the one that works follows the cursor and what I need is one that follows a moving icon at the bottom of the window like the first program does.
blibecap is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Javascript works in ie but not in firefox
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 



Page generated in 0.14892 seconds with 12 queries