Sternenhimmel (4)

Moderator: HTML-Laie

Antworten
Benutzeravatar
Hape
Administrator
Beiträge: 336
Registriert: Fr 22. Mai 2020, 00:33

Sternenhimmel (4)

Beitrag von Hape »

Code: Alles auswählen

<!-- Script-Anfang -->
<!-- www-java24.net - DIE Javascript - Ressource -->

<!--  Diesen Code musst Du in den -head- einbauen -->

<style type="text/css">

body{
background-color:black;
background-image:url('stars.jpeg');
font-size:10pt;
color:white;
font-family:sans-serif;
}
</style>

<script language="javascript">
var starblink=250;            // LENGTH OF TIME STARS TWINKLE ON IN MILLISECONDS
var stardelay=2;               // DELAY BETWEEN TWINKLES IN SECONDS

//  ENTER THE COLORS OF THE STARS IN THE ARRAY BELOW SEPERATED BY COMMAS.
//  YOU CAN USE VALID COLOR NAMES OR HEX COLOR TRIPLETS.
var starcolors=new Array( '#C8C3C2' , '#F304F6' , '#3806F4' , '#E5E201' );

// **** DO NOT EDIT BELOW HERE **** //

var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

var windowW, windowH,star;

function getwindowdims(){
windowW=(ie4||ie5)? document.body.clientWidth: window.innerWidth;
windowH=(ie4||ie5)?  document.body.clientHeight :window.innerHeight;
}

function twinkle(phs,c){
var x,y;
if(phs==2){
x=Math.floor(Math.random()*windowW-2);
y=Math.floor(Math.random()*windowH-2);
if(ns4){
star.visibility="hide"
star.moveTo(x,y);
star.bgColor=starcolors[c];
}else{
star.style.visibility="visible";
star.style.left=x+'px';
star.style.top=y+'px';
star.style.backgroundColor=starcolors[c];
}
setTimeout('twinkle(1,'+(Math.floor(Math.random()*starcolors.length))+')', stardelay);
}else{
(ns4)?star.visibility="show" : star.style.visibility="visible";
setTimeout('twinkle(2,'+c+')',starblink);
}}

document.write( (ns4)? '<layer name="star" left="0" top="0" width="2" height="2" bgcolor="white" visibility="hide"></layer>' : '<div id="star" style="position:absolute; width:2px; height:2px; top:0px; left:0px; font-size:2px; background-color:white; visibility:hidden"></div>');

window.onload=function(){
star=(ns4)?document.layers['star']:(ie4)? document.all['star']:document.getElementById('star');
getwindowdims();
window.onresize=getwindowdims;
twinkle(2,0);
}
</script>

<!-- Script-Ende -->
<!-- www-java24.net - DIE Javascript - Ressource -->
Demoseite hierzu: Sternenhimmel-4

stars.jpeg
stars.jpeg (2.72 KiB) 13130 mal betrachtet

Antworten