/    Sign up×
Community /Pin to ProfileBookmark

This script working in Intenet explorer but not working in other browsers

This script working in Intenet explorer but not working in other browsers.
Please any help me. Here see how it work this script (see with IE): [URL=”http://tprob.hit.bg/”]http://tprob.hit.bg/[/URL]

and here is the code:

[CODE]<script language=”JavaScript”>

P=new Image();

P.src=”2.gif”; file://Pre-load your image here!

Pic=”3.gif”; file://Type your image name here!

amount=15; file://Amount of images, not less than 2!

BY=-20; file://Your image height!

BX=-20; file://Your image width!

S=2; file://speed!

ns=(document.layers)?1:0;

if (ns){

for (i=0; i < amount; i++)

document.write(“<LAYER NAME=’netscape”+i+”‘ LEFT=0 TOP=0><img src=”+Pic+”></LAYER>”);

}

else{

document.write(“<div style=’position:absolute;top:0px;left:0px’><div style=’position:relative’>”);

for (i=0; i < amount; i++)

{document.write(“<img id=’explorer’ src='”+Pic+”‘ style=’position:absolute;top:0px;left:0px’>”)}

document.write(“</div></div>”)

}

R=new Array(),PB=new Array(),RD=new Array(),Y=new Array(),X=new Array(),D=new Array(),VB=0,HB=0,SP=new Array();;

for (i=0; i < amount; i++){Y[i]=10;X[i]=10;D[i]=Math.floor(Math.random()*80+10);SP[i]=Math.floor(Math.random()*S+3)}

function Curve(){

plusMinus=new Array(1,-1,2,-2,3,-3,0,1,-1)

for (i=0; i < amount; i++){

R[i]=Math.floor(Math.random()*plusMinus.length);

RD[i]=plusMinus[R[i]];

}

setTimeout(‘Curve()’,1800);

}

function MoveRandom(){

T=setTimeout(‘MoveRandom()’,10);

var H=(document.layers)?window.innerHeight:document.body.clientHeight;

var W=(document.layers)?window.innerWidth:document.body.clientWidth;

var YS=(document.layers)?window.pageYOffset:document.body.scrollTop;

var XS=(document.layers)?window.pageXOffset:document.body.scrollLeft;

for (i=0; i < amount; i++){

PB[i]=D[i]+=RD[i];

y = SP[i]*Math.sin(PB[i]*Math.PI/180);

x = SP[i]*Math.cos(PB[i]*Math.PI/180);

if (D[i] < 0) D[i]+=360;

Y[i]+=y;

X[i]+=x;

VB=180-D[i];

HB=0-D[i];

file://Corner rebounds! not necessary but looks nice.

if ((Y[i] < 1) && (X[i] < 1)) {Y[i]=1;X[i]=1;D[i]=45;}

if ((Y[i] < 1) && (X[i] > W+BX)) {Y[i]=1;X[i]=W+BX;D[i]=135;}

if ((Y[i] > H+BY) && (X[i] < 1)) {Y[i]=H+BY;X[i]=1;D[i]=315;}

if ((Y[i] > H+BY) && (X[i] > W+BX)) {Y[i]=H+BY;X[i]=W+BX;D[i]=225;}

file://Edge rebounds!

if (Y[i] < 1) {Y[i]=1;D[i]=HB;}

if (Y[i] > H+BY) {Y[i]=H+BY;D[i]=HB;}

if (X[i] < 1) {X[i]=1;D[i]=VB;}

if (X[i] > W+BX) {X[i]=W+BX;D[i]=VB;}

var layer=(document.layers)?document.layers[‘netscape’+i]:explorer[i].style;

layer.top=Y[i]+YS;

layer.left=X[i]+XS;

}

}

function sTaRt(){Curve();MoveRandom()}

if (document.all||document.layers){sTaRt()}

file:

</script>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@xelawhoApr 02.2012 — I have no idea what your function is supposed to do but it seems to me that it is seriously outdated.

document.layers is testing for netscape 4

document.all is testing for IE4

ancient, ancient browsers that I would bet are completely unused now.

and you don't appear to be testing for anything else ?
Copy linkTweet thisAlerts:
@WolfShadeApr 03.2012 — Not to mention that things like "file://Pre-load your image here!" should be commented out. These are probably breaking the function, even if it weren't outdated.
×

Success!

Help @gorski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...