Chciałbym na swojej stronce wstawić latajaca pszczółkę (IMG:
style_emoticons/default/smile.gif) No i znalazłem taki skrypt java:
o = document.getElementById('bzyk')
move=1;
function Curve(){
abc
=new Array(0
,1
,1
,1
,2
,3
,4
,0
,6
,-1
,-1
,-1
,-2
,-3
,-4
,0
,-6
)for (i=0; i < abc.length; i++)
{var C
=Math
.round(Math
.random
()*[i
])} howbend=abc[C];
setTimeout('Curve()',1900);
return howbend;
}
ypos=10;
xpos=10;
degree = 60;
function MoveRandom(){
PathBend=degree+=howbend;//ok!
y = 4*Math.sin(PathBend*Math.PI/180)
x = 6*Math.cos(PathBend*Math.PI/180)
ypos+=y;
xpos+=x;
if (document.all){
o.style.top=ypos+document.body.scrollTop;
o.style.left=xpos+document.body.scrollLeft;
} else {
o.style.top=ypos+window.pageYOffset+'px';
o.style.left=xpos+window.pageXOffset+'px';
}
T=setTimeout('MoveRandom()',50);
}
function edges(){
if (document.all)
{
if (o.style.pixelLeft >=
document
.body
.offsetWidth
-45
+document
.body
.scrollLeft
)degree
=Math
.round(Math
.random
()*45
+157
.5
);if (o.style.pixelTop >=
document
.body
.offsetHeight
-35
+document
.body
.scrollTop
)degree
=Math
.round(Math
.random
()*45
-112
.5
);if (o.style.pixelTop <= 2+document.body.scrollTop) degree =
Math
.round(Math
.random
()*45
+67
.5
);//OK!if (o.style.pixelLeft <= 2+document.body.scrollLeft) degree =
Math
.round(Math
.random
()*45
-22
.5
);//OK!} else {
if (o.offsetLeft >=
window
.innerWidth
-40
+window
.pageXOffset
)degree
=Math
.round(Math
.random
()*45
+157
.5
);if (o.offsetTop >=
window
.innerHeight
-30
+window
.pageYOffset
)degree
=Math
.round(Math
.random
()*45
-112
.5
);if (o.offsetTop <= 2+window.pageYOffset) degree =
Math
.round(Math
.random
()*45
+67
.5
);//OK!if (o.offsetLeft <= 2+window.pageXOffset) degree =
Math
.round(Math
.random
()*45
-22
.5
);//OK!}
setTimeout('edges()',100);
}
function starteffect(){
Curve();
MoveRandom();// onUnload="opener.gO()"
edges();
}
tutaj:
o = document.getElementById('bzyk')
słowo: 'bzyk' oznacza nazwę pliku graficznego: bzyk.gif
W pliku index.html dodaję:
<div id="bzyk" style="text/javascript" src="bzyk.js"><img src="bzyk.gif" width="35" height="40"></div> <script type="text/javascript" src="bzyk.js">
No i obrazek pszczółki się wyświetla ale nie lata... Może mi ktoś poradzić co jest nie tak? W JAVIE jestem zielony. (IMG:
style_emoticons/default/worriedsmiley.gif)
Powód edycji: [Cysiaczek]: zmieniłem tag