»
EnglishFrenchVietnamese

Print - Flying Messages - JavaScriptBank.com

Full version: jsB@nk » Text » Animation » Flying Messages
URL: https://www.javascriptbank.com/flying-messages.html

Flying Messages © JavaScriptBank.comThis JavaScript will make the messages fly from two side to center of window.

Full version: jsB@nk » Text » Animation » Flying Messages
URL: https://www.javascriptbank.com/flying-messages.html



CSS
<STYLE type=text/css>.fly1 {COLOR: white; FONT-FAMILY: arial; FONT-SIZE: 22pt; FONT-WEIGHT: bold; POSITION: absolute}.fly2 {COLOR: white; FONT-FAMILY: timesroman; FONT-SIZE: 24pt; FONT-WEIGHT: bold; POSITION: absolute}.fly3 {COLOR: white; FONT-FAMILY: gothic; FONT-SIZE: 26pt; FONT-WEIGHT: bold; POSITION: absolute}.fly4 {COLOR: white; FONT-FAMILY: arial; FONT-SIZE: 28pt; FONT-WEIGHT: bold; POSITION: absolute}.fly5 {COLOR: white; FONT-FAMILY: courier; FONT-SIZE: 29pt; FONT-WEIGHT: bold; POSITION: absolute}.fly6 {COLOR: white; FONT-FAMILY: arial; FONT-SIZE: 22pt; FONT-WEIGHT: bold; POSITION: absolute}.fly7 {COLOR: white; FONT-FAMILY: timesroman; FONT-SIZE: 20pt; FONT-WEIGHT: bold; POSITION: absolute}.fly8 {COLOR: white; FONT-FAMILY: gothic; FONT-SIZE: 22pt; FONT-WEIGHT: bold; POSITION: absolute}.fly9 {COLOR: white; FONT-FAMILY: arial; FONT-SIZE: 24pt; FONT-WEIGHT: bold; POSITION: absolute}.fly10 {COLOR: white; FONT-FAMILY: courier; FONT-SIZE: 25pt; FONT-WEIGHT: bold; POSITION: absolute}.mesg {COLOR: white; FONT-FAMILY: arial; POSITION: relative}</STYLE><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


JavaScript
<SCRIPT language=JavaScript>var message = "JavaScriptBank.com - Bank of over 2000+ free JavaScripts";var finalmessage = "<a href='www.JavaScriptBank.com'>Enter</a>";//so luong chu bay, neu thay doi ban phai thay doi luon kieu,mau chu va the <style> ben duoivar noOfFlyers = 10; //mau chuvar blkCol = new Array("white","blue","red","white","red","blue","white","blue","red","white"); // mau chu//kieu fontvar blkFont = new Array("arial"," verdana "," arial ","verdana"," arial "," verdana","arial"," arial "," verdana ","arial");//kich co fontvar blkSize = new Array("22","14","10","28","29","10","22","24","26","10");var blkIt = new Array("0","0","1","0","1","0","0","1","0","0");var ie=document.all?1:0var ns=document.layers?1:0var err = 0;var msgI=1;var noOfMsgs;function initialize(){if(!ns&&!ie) {document.writeln("<center>"+finalmessage+"</center>");document.writeln("<P><P><font face='arial' size=2>Because your browser is too rubbish, you cannot see this so hurry up and upgrade!</font>");err=1;return;}if(noOfFlyers<1||noOfFlyers>10) {handleErr("The number of flying blocks has been assigned an invalid value. Script will terminate.");return}if(blkCol.length!=noOfFlyers) {handleErr("The list of block colours has an invalid length. Script will terminate.");return}if(blkFont.length!=noOfFlyers) {handleErr("The list of block fonts has an invalid length. Script will terminate.");return}if(blkSize.length!=noOfFlyers) {handleErr("The list of block font sizes has an invalid length. Script will terminate.");return}self.moveTo(0,0);self.resizeTo(screen.width,screen.height);var msg = new String(message);aOMsgs = msg.split(" ");noOfMsgs = aOMsgs.length+1;for(var i = 0; i<aOMsgs.length; i++){for(var j = 1; j<=noOfFlyers; j++){if(ie) document.writeln("<div id=\"fly"+String((i*noOfFlyers)+j)+"\" class=\"fly"+String(j)+"\" style=\"visibility:hidden\">"+aOMsgs[i]+"</div>");if(ns) document.writeln("<layer id=\"fly"+String((i*noOfFlyers)+j)+"\" class=\"fly"+String(j)+"\" visibility=\"hidden\">"+aOMsgs[i]+"</layer>");}}if(ie) document.write("<div id=\"mesg\" style=\"position:relative;color:black;visibility:hidden;font-family:arial;\"><center>"+finalmessage+"</center></div>");if(ns) document.write("<layer id=\"mesg\" class=\"mesg\" visibility=\"hidden\"><center>"+finalmessage+"</center></layer>");}var msgCol=0;function stop_flying(){if(ie){document.all.mesg.style.visibility="visible";document.all.mesg.style.color="rgb("+String(msgCol)+","+String(msgCol)+","+String(msgCol)+")";      }if(ns){setTimeout("document.layers['mesg'].visibility='visible'",1000);return;      }msgCol+=10;if(msgCol<256) setTimeout("stop_flying()",10);else return;}function fly_txt(dataID){this.objID = dataID;var screen_x = screen.width;var screen_y = screen.height;var window_x = 0.9*screen_x;var window_y = 0.6*screen_y;var x;x=0.6*Math.random();if(x>0.3) x+=0.4;this.start_x = Math.round(window_x*x);this.start_y = Math.round(window_y*Math.random());if(x>0.3) x=0.3*Math.random();else x=0.7+0.3*Math.random();this.stop_x = Math.round(window_x*x);this.stop_y = Math.round(window_y*Math.random());        this.slope = (this.stop_y - this.start_y)/(this.stop_x - this.start_x);this.speed = Math.round(Math.random()*2)+4;if(ns) this.speed-=2;this.steps = Math.round(Math.abs(this.start_x-this.stop_x)/this.speed);this.curCol = 0;this.curI = 0;this.timerID = 0;if(ie) this.objStyle = eval("document.all(\""+this.objID+"\").style");if(ns) this.objStyle = eval("document.layers[\""+this.objID+"\"]");var tmp = (parseInt(dataID.substring(3))-1)%noOfFlyers;if(ie) {this.color=blkCol[tmp];this.objStyle.fontFamily=blkFont[tmp];this.objStyle.fontSize=blkSize[tmp]+"pt";this.objStyle.fontStyle=(parseInt(blkIt[tmp])?"italic":"normal");}this.Animate = animate_fly;}function animate_fly(){if(ie){ this.objStyle.pixelLeft = this.start_x+this.curI;this.objStyle.pixelTop = (this.slope*this.curI) + this.start_y;}if(ns){this.objStyle.left = this.start_x+this.curI;this.objStyle.top = (this.slope*this.curI) + this.start_y;}this.objStyle.visibility="visible";if(this.stop_x>this.start_x) this.curI+=this.speed;else this.curI-=this.speed;if(ie){var tmp;switch(this.color){case "white":tmp=String("rgb("+String(this.curCol)+","+String(this.curCol)+","+String(this.curCol)+")");break;case "red":tmp=String("rgb("+String(this.curCol)+",0,0)");break;case "blue":tmp=String("rgb(0,0,"+String(this.curCol)+")");break;case "green":tmp=String("rgb(0,"+String(this.curCol)+",0)");break;default:}        this.objStyle.color=tmp;if(this.steps>50){if(Math.abs(this.curI/this.speed)<25) this.curCol+=10;if(Math.abs(this.curI/this.speed)>(this.steps-25)) this.curCol-=5;}}if(Math.abs(this.start_x+this.curI-this.stop_x)<=this.speed) {clearInterval(this.timerID);this.timerID=0;this.objStyle.visibility="hidden";var end=0;for(var i=1; i<=noOfFlyers; i++)if(fly[i].timerID) end=1;if(!end)if(msgI<noOfMsgs) start_flying(msgI++);else stop_flying();}}var fly = new Array(11);function start_flying(msgIndex){if(err) return;        for(var s=1; s<=noOfFlyers; s++){fly[s] = new fly_txt("fly"+String((msgIndex-1)*noOfFlyers+s));}for(s=1;s<=noOfFlyers;s++){var cmd = "fly["+s+"].Animate()";fly[s].timerID = setInterval(cmd,10);}}function handleErr(errMsg){alert(errMsg);err=1;return false;}//--></SCRIPT><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<BODY bgColor=black onload=start_flying(msgI++) text=white><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->