Ik heb een javascript code omgebouwd, voor het maken van een 'typewriter'-effect.
Ik wil nu iets inbouwen dat wanneer je in de invoertekst een bepaald teken gebruikt (bijvoorbeeld:
, dat er dan een <br> in de html van de layer komt, zodat de rest van de tekst op een nieuwe regel komt.
Ik heb al iets geprobeerd in de 'spellit'-functie, maar dat werkt niet.
Wie helpt me?
Ik wil nu iets inbouwen dat wanneer je in de invoertekst een bepaald teken gebruikt (bijvoorbeeld:
Ik heb al iets geprobeerd in de 'spellit'-functie, maar dat werkt niet.
Wie helpt me?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
| <div id='anima' style="position:absolute;font-family:Verdana;font-size:10;background-color:white;; left: 323px; top: 134px; width: 235px; height: 300px">
</div>
text = "Dit is de invoertekst * dit moet op de volgende regel"
word = text.split(' ')
i = 0;
j = 0;
function spellit(string)
{
with(document.all.anima)
{
if(i <= string.length)
{
if(i <= string.length - 1)
{
i++;
if(string.substring(i-1,i)=="*")
{
innerText = string.substring(0,i-1) + "<br>";
}
else
{
innerText = string.substring(0,i);
}
mistake = 'spellit("' + string + '")';
setTimeout("eval(mistake)", 50);
}
else
{
innerText = string.substring(0, i);
j++;
call_It();
}
}
}
}
function call_It()
{
with(document.all)
{
if(j <= word.length - 1)
{
spellit(anima.innerText + " " + word[j]);
}
}
}
if(document.all)
{
call_It();
} |
Ik blijf er iig vrij nuchter onder....