Halloween Effect - Website

Status
Niet open voor verdere reacties.

iKnow

Gebruiker
Lid geworden
31 aug 2012
Berichten
44
Hi Mensen!

Ik heb al verschillende website gezien waar er bijvoorbeeld tijdens de kerstmis of nieuwjaar
sneeuw door het beeldscherm vliegt. Of 'Vliegt' dat het gewoon sneeuwt.

Ik weet niet of er ook een cool Halloween effect hiervoor bestaat?
Dus dat er bijvoorbeeld van die kleine schimmen door het beeld heen vliegen.
Iemand?

Alvast Bedankt!


Mvg, iKnow
 
sneeuw op website

hai

gaat zeker met onderstaand java bestand als html in te voegen onder background
en een snow.gif in je basisroot zetten bijv snow.gifsnow.gif

grtjs

droomwever
<!-- begin snow-->
<script language="JavaScript1.2"
src="snow2.js"
type="text/javascript"></script>
<!-- end snow -->
<div id="paginatitelBackground"></div>

<!-- begin snow -->
<script language="javascript">


ns6 = document.getElementById;
ns = document.layers;
ie = document.all;


/*******************[AccessCSS]***********************************/
function accessCSS(layerID) { //
if(ns6){ return document.getElementById(layerID).style;} //
else if(ie){ return document.all[layerID].style; } //
else if(ns){ return document.layers[layerID]; } //
}/***********************************************************/


/**************************[move Layer]*************************************/
function move(layer,x,y) { accessCSS(layer).left=x; accessCSS(layer).top = y; }


function browserBredde() {
if (window.innerWidth) return window.innerWidth;
else if (document.body.clientWidth) return document.body.clientWidth;
else return 1024;
}

function browserHoyde() {

if (window.innerHeight) return window.innerHeight;
else if (document.body.clientHeight) return document.body.clientHeight;
else return 800;
}

function makeDiv(objName,parentDiv,w,h,content,x,y,overfl,positionType)
{
// positionType could be 'absolute' or 'relative'

if (parentDiv==null) parentDiv='body';

var oDiv = document.createElement ("DIV");
oDiv.id = objName;

if (w) oDiv.style.width = w;
if (h) oDiv.style.height= h;


if (content) oDiv.innerHTML=content;
if (positionType==null) positionType="absolute";
oDiv.style.position = positionType;
if (x) oDiv.style.left=x; else oDiv.style.left=-2000;
if (y) oDiv.style.top=y; else oDiv.style.top=-2000;


if (overfl) oDiv.style.overflow=overfl; else oDiv.style.overflow="hidden";
eval(' document.'+parentDiv+'.appendChild (oDiv); ');

delete oDiv;
}

var snowC=0;
var x = new Array();
var y = new Array();
var speed = new Array();
var t=0;
var cC = new Array();
var ra = new Array();

function makeSnow() {
x[snowC] = Math.round(Math.random()*(browserBredde()-60));
y[snowC] = 10;
makeDiv("snow"+snowC,"body",24,24,'<img src="snow.gif">');
speed[snowC] = Math.round(Math.random()*8)+1;
cC[snowC]=Math.random()*10;
ra[snowC] = Math.random()*7;
snowC++;

}


function moveSnow() {
var r = Math.round(Math.random()*100);
if (r>70 && snowC<20) makeSnow();

for (t=0;t<snowC;t++) {
y[t]+=speed[t];move("snow"+t,x[t],y[t]);
if (y[t]>browserHoyde()-50) {y[t] = 10;x[t] = Math.round(Math.random()*(browserBredde()-60));}
cC[t]+=0.01;
x[t]+=Math.cos(cC[t]*ra[t]);

}

setTimeout('moveSnow()',20);
}

moveSnow();



</script>
<!-- end snow -->
 
Ah, nog even als nabrander, of voor volgend jaar:


  • Bovenstaand script is niet cross-browser (resp. kan niet tegen elk Doctype) ...
  • In dit topic een script voor vliegende voorwerpen dat in de meeste gevallen wel werkt.

Met vriendelijke groet,
CSShunter
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan