Titel-effect-Zufallsgenerator funktioniert nicht!
Christopher
- javascript
Hallo
Was ist an diesem Titeleffectzufallsgenerator falsch? Es kommt keine Fehlermeldung, aber der Titel ist nicht annimiert!!! Was mache ich falsch???
Cu,
Christopher
Hier der ganze Code:
function titel1() {
// *******************************************************************
// script by drevil_nz, Michael Dillon, Christchurch New Zealand.
// Permission granted to use this script provided this credit
// remains intact. Visit my homepage www.chc.quik.co.nz/juggler/mikey.html
// Script written for Internet Explorer 4.0+.
// *******************************************************************
var message="Michael Dillon's dynamic title script" //specifys the title
var message=message+" " //gives a pause at the end,1 space=1 speed unit, here I used 10 spaces@150 each = 1.5seconds.
i="0" //declares the variable and sets it to start at 0
var temptitle="" //declares the variable and sets it to have no value yet.
var speed="150" //the delay in milliseconds between letters
function titler(){
if (!document.all&&!document.getElementById)
return
document.title=temptitle+message.charAt(i) //sets the initial title
temptitle=temptitle+message.charAt(i) //increases the title by one letter
i++ //increments the counter
if(i==message.length) //determines the end of the message
{
i="0" //resets the counter at the end of the message
temptitle="" //resets the title to a blank value
}
setTimeout("titler()",speed) //Restarts. Remove line for no-repeat.
}
window.onload=titler
}
function titel2() {
/*
Animated Document title- By Dynamicdrive.com
For full source, TOS, and 100s DTHML scripts
Visit http://dynamicdrive.com
*/
if (document.all||document.getElementById){
var thetitle=document.title
document.title=''
}
////Animation code below
////based on script from http://wsabstract.com/script/script2/statusanimate.shtml
var data="0123456789";
var done=1;
function statusIn(text){
decrypt(text,2,1);
}
function statusOut(){
self.status='';
done=1;
}
//-------------------------\
//decrypt(string, int, int)\
//-------------------------\
//
//text(string): the text to be decrypted on
//the status bar.
//
//max(int): the number of times a random string
//is displayed before the next character is
//'decrypted'.
//
//delay(int): the number of milliseconds between
//each display of a random string
//
//Example:
//decrypt('Enter my site.',10,10);
//
//text = 'Enter my site.' :: 'Enter my site.' is
//eventually decrypted
//
//max = 10 :: a different random string is dis-
//played 10 times before a new character is
//decrypted
function decrypt(text, max, delay){
if (done){
done = 0;
decrypt_helper(text, max, delay, 0, max);
}
}
function decrypt_helper(text, runs_left, delay, charvar, max){
if (!done){
runs_left = runs_left - 1;
var status = text.substring(0,charvar);
for(var current_char = charvar; current_char < text.length; current_char++){
status += data.charAt(Math.round(Math.random()*data.length));
}
document.title = status;
var rerun = "decrypt_helper('" + text + "'," + runs_left + "," + delay + "," + charvar + "," + max + ");"
var new_char = charvar + 1;
var next_char = "decrypt_helper('" + text + "'," + max + "," + delay + "," + new_char + "," + max + ");"
if(runs_left > 0){
setTimeout(rerun, delay);
}
else{
if (charvar < text.length){
setTimeout(next_char, Math.round(delay*(charvar+3)/(charvar+1)));
}
else
{
done = 1;
}
}
}
}
//if IE 4+ or NS 6+
if (document.all||document.getElementById)
statusIn(thetitle)
}
var titeleffectbsp = new Array('titel1();','titel2();','');
var x = Math.floor(Math.random() * titeleffectbsp.length);
titeleffectbsp[x];
Warum es nicht funktioniert, kann ich dir nicht sagen...
Was ich dir aber sagen kann, ist, dass der Title durchaus seine Berechtigung hat und weniger ein Spielzeug ist. Insofern sollte sowas auch nicht nach dem Zufallsprinzip bestimmt werden! ;-)
Gruß Patrick