Welcome-Message

Moderator: HTML-Laie

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

Welcome-Message

Beitrag von Hape »

Hier ein Script das eine Message im Hintergrund über den Bildschirm laufen läßt.

Code: Alles auswählen

<script type="text/javascript">

//Welcome Message - http://www.btinternet.com/~kurt.grigg/javascript

if  ((document.getElementById) &&
window.addEventListener || window.attachEvent){


if  (!window.opera){

(function(){

//Configure here.

var message = "Herzlich Willkommen auf dieser Seite!"; //your message.
var col = new Array('#ff0000','#00aa00','#0000ff'); //add more if needed.
var xyz = 26; //max grow size.
var spd = 30; //setTimeout speed.

//End.

var msg = message.split(" ");
var timer = null;
var clrPos = 0;
var msgPos = 0;
var jog = 1;
var currentStep = 10;
var step = 8;
var h,w,y,x,r,xy;
var d = document;
var pix = "px";
var domWw = (typeof window.innerWidth == "number");
var domSy = (typeof window.pageYOffset == "number");
var running = true;
var box,txt;
var ovrflw =  (d.documentElement.style &&
typeof d.documentElement.style.MozOpacity == "string")
?"-moz-scrollbars-none":"hidden";
var idx = d.getElementsByTagName('div').length;

d.write("<div id='_box"+idx+"' style='position:absolute;top:0px;left:0px;"
+"height:10px;width:10px;text-align:center;overflow:"+ovrflw+"'>"
+"<div id='_txt"+idx+"' style='position:absolute;top:0px;left:0px;width:1px;"
+"height:1px;font-family:arial,sans-serif;font-size:1px'>.</div></div>");

if (domWw) r = window;
else{
  if (d.documentElement &&
  typeof d.documentElement.clientWidth == "number" &&
  d.documentElement.clientWidth != 0)
  r = d.documentElement;
 else{
  if (d.body &&
  typeof d.body.clientWidth == "number")
  r = d.body;
 }
}

function winsize(){
var oh,sy,ow,sx,rh,rw;
if (domWw){
  if (d.documentElement && d.defaultView &&
  typeof d.defaultView.scrollMaxY == "number"){
  oh = d.documentElement.offsetHeight;
  sy = d.defaultView.scrollMaxY;
  ow = d.documentElement.offsetWidth;
  sx = d.defaultView.scrollMaxX;
  rh = oh-sy;
  rw = ow-sx;
 }
 else{
  rh = r.innerHeight;
  rw = r.innerWidth;
 }
h = rh;
w = rw;
}
else{
h = r.clientHeight;
w = r.clientWidth;
}
y = Math.floor(h/2);
x = Math.floor(w/2);

xy = (w >= h)?w:h;
}

function scrl(yx){
var sy,sx;
if (domSy){
 sy = r.pageYOffset;
 sx = r.pageXOffset;
 }
else{
 sy = r.scrollTop;
 sx = r.scrollLeft;
 }
return (yx == 0)?sy:sx;
}

function dsply(){
step += 15;
currentStep += step;

txt.top = y + Math.floor(-currentStep/16) + pix;
txt.left = x + Math.floor(-currentStep/2) + pix;
txt.width = currentStep + pix;
txt.fontSize = Math.floor(currentStep/8) + pix;
txt.color = col[clrPos];
d.getElementById("_txt"+idx).firstChild.data = msg[msgPos];
if (currentStep > xy * xyz){
 currentStep = 10;
 step = 8;
 msgPos += jog;
 clrPos += jog;
}
if (clrPos >= col.length){
 clrPos = 0;
}
timer = setTimeout(dsply,spd);
if (msgPos >= msg.length){
 running = false;
 box.width = 1 + pix;
 box.height = 1 + pix;
 box.visibility = "hidden";
 txt.width = 1 + pix;
 txt.height = 1 + pix;
 txt.visibility = "hidden";
 clearTimeout(timer);
 }
box.top = scrl(0) + pix;
box.left = scrl(1) + pix;
}

function dims(){
if (domWw) box.width = "100%";
else box.width = w + pix;
box.height = h + pix;
}

function init(){
 winsize();
 box = document.getElementById("_box"+idx).style;
 txt = document.getElementById("_txt"+idx).style;
 dims();
 dsply();
}

function rsz(){
 if (running){
  winsize();
  dims();
 }
}

if (window.addEventListener){
 window.addEventListener("resize",rsz,false);
 window.addEventListener("load",init,false);
}
else if (window.attachEvent){
 window.attachEvent("onresize",rsz);
 window.attachEvent("onload",init);
}

})();
}
}//End.

</script>
Hier die Demoseite dazu: Welcome

Antworten