How to Add Shooting Star or Comet Effects in Blogger
Go to Blogger Dashboard
Click Template >> Edit HTML
Look for the code below
</head>
Just above that code, paste the code below
<script type="text/javascript">
// <![CDATA[
var speed=25; // how fast - smaller is faster
var how_often=10; // average time between re-appearances of a comet (in seconds)
var how_many=10; // maximum number of comets in flight
var colours=new Array("#ff0", "#f93", "#f60", "#e93", "#e94", "#da5", "#da6", "#cb7", "#cb8", "#cc9", "#dcb", "#ddd");
// above line lists colours for the comet and its tail (can be as long or short as you like)
/****************************
* Shooting Star/Comet Effect*
*Bloggingtipsandtrix*
* DON'T EDIT BELOW THIS BOX *
****************************/
var dx=new Array();
var dy=new Array();
var xpos=new Array();
var ypos=new Array();
var comets=new Array();
var swide=800;
var shigh=600;
var tail=colours.length;
var boddie=false;
function addLoadEvent(funky) {
var oldonload=window.onload;
if (typeof(oldonload)!='function') window.onload=funky;
else window.onload=function() {
if (oldonload) oldonload();
funky();
}
}
addLoadEvent(whooosh);
function whooosh() { if (document.getElementById) {
var i;
boddie=document.createElement("div");
boddie.style.position="fixed";
boddie.style.top="0px";
boddie.style.left="0px";
boddie.style.overflow="visible";
boddie.style.width="1px";
boddie.style.height="1px";
boddie.style.backgroundColor="transparent";
document.body.appendChild(boddie);
set_width();
for (i=0; i<how_many; i++) {
write_comet(i*tail);
setTimeout('launch('+(i*tail)+')', Math.max(1000*i));
}
}}
function write_comet(a) {
var i, s;
for (i=0; i<tail; i++) {
s=2+(i<tail/4)+2*!i;
comets[i+a]=div(s, s);
comets[i+a].style.backgroundColor=colours[i];
boddie.appendChild(comets[i+a]);
}
}
function div(w, h) {
var d=document.createElement("div");
d.style.position="absolute";
d.style.overflow="hidden";
d.style.width=w+"px";
d.style.height=h+"px";
return (d);
}
function stepthrough(a) {
var i;
if (Math.random()<0.008||ypos[a]+dy[a]<5||xpos[a]+dx[a]<5||xpos[a]+dx[a]>=swide-5||ypos[a]+dy[a]>=shigh-5) {
for (i=0; i<tail; i++) setTimeout('comets['+(i+a)+'].style.visibility="hidden"', speed*(tail-i));
setTimeout('launch('+a+')', Math.max(1000, 2000*Math.random()*how_often));
}
else setTimeout('stepthrough('+a+')', speed);
for (i=tail-1; i>=0; i--) {
if (i) {
xpos[i+a]=xpos[i+a-1];
ypos[i+a]=ypos[i+a-1];
}
else {
xpos[i+a]+=dx[a];
ypos[i+a]+=dy[a];
}
comets[i+a].style.left=xpos[i+a]+"px";
comets[i+a].style.top=ypos[i+a]+"px";
}
}
function launch(a) {
var i;
dx[a]=(Math.random()>0.5?1:-1)*(1+Math.random()*3);
dy[a]=(Math.random()>0.5?1:-1)*((7-dx[a])/3+Math.random()*(dx[a]+5)/3);
xpos[a]=2*tail*dx[a]+Math.round(Math.random()*(swide-4*tail*dx[a]));
ypos[a]=2*tail*dy[a]+Math.round(Math.random()*(shigh-4*tail*dy[a]));
for (i=0; i<tail; i++) {
xpos[i+a]=xpos[a];
ypos[i+a]=ypos[a];
comets[i+a].style.visibility="visible";
}
stepthrough(a);
}
window.onresize=set_width;
function set_width() {
var sw_min=999999;
var sh_min=999999;
if (document.documentElement && document.documentElement.clientWidth) {
if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
}
if (typeof(self.innerWidth)!="undefined" && self.innerWidth) {
if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
}
if (document.body.clientWidth) {
if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
}
if (sw_min==999999 || sh_min==999999) {
sw_min=800;
sh_min=600;
}
swide=sw_min;
shigh=sh_min;
}
// ]]>
</script>
Save your Template and Bravo!
From: mf2fm
About the Author:
Hello folks! This is GOLDEN WORKS TV, the admin of this blog. No words could described my grateful appreciations to all newbie and professional bloggers around the world and most especially to Almighty God who gave me the wisdom...Read More
No comments :
Post A Comment!
Post A Comment!
We love to hear your feedbacks and suggestions. We will try our best to reply to your queries as soon as time allows. Please keep in mind that all comments are moderated manually by our editors team to minimize spamming, and all the links are nofollow.
Note:
1. To add HTML code in the box, please use our HTML editor generator.
2. Please do not spam. Those type of comments will be deleted upon our review.
3. We should appreciate an individual and suggestive discussion.
Best Regards,
GOLDEN WORKS TV