Hallo ,
ich habe hier mal ein Javascript gefunden das mir einen Text schreibt. Also Zeichen für Zeichen. Funktioniert auch alles super nur ist es leider so das das Javascript immer und immer wieder durchläuft. Ich möchte aber das es nur einmal ausgeführt wird und dann stoppt. Wie löse ich dass denn ?
Hier mal das Javascript
Code
var textticker_data = new Array();var textticker_cursor = '#';
var textticker_delay_line = 1000;
var textticker_delay_char = 50;
var textticker_x, textticker_y, textticker_id, textticker_line;
function textticker_define(line) {
textticker_data[textticker_data.length] = line;
}
function textticker_next() {
if (textticker_x++ == textticker_data[textticker_y].length) {
textticker_x = 0;
textticker_line = '';
if (textticker_y++ == textticker_data.length-1) {
textticker_y = 0;
}
return true;
} else {
return false;
}
}
function textticker_update() {
if (textticker_data[textticker_y].charAt(textticker_x) == '#') {
setTimeout('textticker_update()',
1000*textticker_data[textticker_y].charAt(textticker_x+1));
textticker_x++;
textticker_next();
} else {
textticker_line = textticker_line
+ textticker_data[textticker_y].charAt(textticker_x);
container = document.getElementById(textticker_id);
container.innerHTML = textticker_line+textticker_cursor;
if (textticker_next())
setTimeout('textticker_update()', textticker_delay_line);
else
setTimeout('textticker_update()', textticker_delay_char);
}
}
function textticker_start(id, cursor, delayline, delaychar) {
textticker_id = id;
textticker_cursor = cursor;
textticker_delay_line = delayline;
textticker_delay_char = delaychar;
textticker_x = 0;
textticker_y = 0;
textticker_line = '';
textticker_update();
}
Alles anzeigen
und hier mal die test Site
Code
<head>
<title>Ticker-Beispiel</title>
<script type="text/javascript" src="textticker.js"></script>
<script type="text/javascript">
function myticker() {
textticker_define('<p class="wargames">CHESS<br>#1POKER<br>#1FIGHTER COMBAT<br>#1GUERRILLA ENGAGEMENT<br>#1DESERT WARFARE<br>#1AIT-TO-GROUND ACTIONS<br>#1THEATERWIDE TACTICAL WARFARE<br>#1THEATERWIDE BIOTOXIC AND CHEMICAL WARFARE<br><br>#1GLOBAL THERMONUCLEAR WAR<br><br>DO YOU WANT TO PLAY A GAME ?<br><br><input class="wargames" name="loginpw" type="text" ></p>');
textticker_start('meinticker', '#', 1000, 50);}
</script>
</head>
<body onload="myticker();">
<div id="meinticker" style="width:100%;"></div>
</body>
</html>
Alles anzeigen
vielen Dank schonmal