terbaik
New member
Hi Leute,
Ich habe folgendes Problem:
Ich habe folgenden Code geschrieben:
Das funktioniert auch perfekt.
Nur wenn ich die Funktion zweimal direkt hintereinander aufrufe, dann kommt das ganze script natürlich durcheinander, weil der vorherige Funktionsaufruf noch nicht fertig ist. Wie kann ich sicherstellen, dass ein zweiter Funktionsaufruf erst dann ausgeführt wird, wenn der erste fertig ist?
Danke schonmal für eure Zeit und Hilfe!
terbaik
Ich habe folgendes Problem:
Ich habe folgenden Code geschrieben:
HTML:
<HTML>
<head>
<script src="jquery.js"></script>
<style>
#toolbar{
position: fixed;
left:0;
top:0;
width: 100%;
background: black;
opacity: 0.8;
padding: 5px;
min-height: 23px;
}
#infobox{
font-family: arial;
font-size: 10pt;
border-radius: 5px;
padding-left: 5px;
padding-right: 5px;
background: orange;
opacity: 0;
width: 300px;
min-height: 10px;
//visibility: hidden;
}
</style>
<script>
function showMessage(type, text){
var origtext = text;
if(text.length > 30){
text = text.substr(0,26);
text += "...";
}
var imgpath = "./img/icons/toolbar/infobox/";
var t = "NOTIFICATION";
if(type=="ERROR"){
t="ERROR";
}else if(type=="HELP"){
t="HELP";
}
if(t=="NOTIFICATION"){
document.getElementById("infobox").style.background = "orange";
document.getElementById("infobox").innerHTML = "<img src=\""+imgpath+"notification.png\">";
}else if(t=="ERROR"){
document.getElementById("infobox").style.background = "red";
document.getElementById("infobox").innerHTML = "<img src=\""+imgpath+"error.png\">";
}else if(t=="HELP"){
document.getElementById("infobox").style.background = "lightblue";
document.getElementById("infobox").innerHTML = "<img src=\""+imgpath+"help.png\">";
}
document.getElementById("infobox").style.height = "23px";
document.getElementById("infobox").style.width = "15px";
$('#infobox').animate({
opacity: 0.6,
}, 500, function() {
$('#infobox').delay(100).animate({
width: '300px',
}, 500, function(){
document.getElementById('infobox').innerHTML+=text;
$('#infobox').delay(5000).animate({
opacity: 0.6,
}, 1000, function(){
var content = infobox.innerHTML;
var newContent = content.substr(0,content.length-text.length);
document.getElementById('infobox').innerHTML=newContent;
$('#infobox').animate({
width: '15px',
}, 500, function(){
$('#infobox').delay(100).animate({
opacity: 0,
}, 500);
});
});
});
});
}
</script>
</head>
<body>
<div id="toolbar">
<div id="infobox"><img src="./img/icons/toolbar/infobox/notification.png"></div>
</div>
<script>
showMessage("NOTIFICATION", "Erfolgreich eingeloggt");
</script>
</body>
</HTML>
Das funktioniert auch perfekt.
Nur wenn ich die Funktion zweimal direkt hintereinander aufrufe, dann kommt das ganze script natürlich durcheinander, weil der vorherige Funktionsaufruf noch nicht fertig ist. Wie kann ich sicherstellen, dass ein zweiter Funktionsaufruf erst dann ausgeführt wird, wenn der erste fertig ist?
Danke schonmal für eure Zeit und Hilfe!
terbaik