Z
ziobudda
Hi all. I have this code:
<html>
<head>
<script language="javascript" type="text/javascript">
function sleep(n)
{
var now = new Date();
var exitTime = now.getTime() + (n*1000);
while (true) {
now = new Date();
if (now.getTime() > exitTime) return;
}
}
function mostra() {
tmp = document.createElement('input');
tmp.setAttribute('type','text');
tmp2= document.getElementById('miodiv');
tmp2.appendChild(tmp);
//Only for try
tmp2.innerHTML = tmp2.innerHTML;
sleep(1);
}
</script>
</head>
<body>
<a href="#" onclick="mostra()">Clicca</a>
<div id="miodiv" style=""></div>
</body>
</html>
Ok ? I need to insert something into "miodiv" (an input type in this
case) and stop javascript for 1 second.
Now my problem: the "input type" is write into "miodiv" only after that
the sleep() function is terminated.
I don't know why.
Tnx.
PS: anyone have a sleep() function that works ?
M.
<html>
<head>
<script language="javascript" type="text/javascript">
function sleep(n)
{
var now = new Date();
var exitTime = now.getTime() + (n*1000);
while (true) {
now = new Date();
if (now.getTime() > exitTime) return;
}
}
function mostra() {
tmp = document.createElement('input');
tmp.setAttribute('type','text');
tmp2= document.getElementById('miodiv');
tmp2.appendChild(tmp);
//Only for try
tmp2.innerHTML = tmp2.innerHTML;
sleep(1);
}
</script>
</head>
<body>
<a href="#" onclick="mostra()">Clicca</a>
<div id="miodiv" style=""></div>
</body>
</html>
Ok ? I need to insert something into "miodiv" (an input type in this
case) and stop javascript for 1 second.
Now my problem: the "input type" is write into "miodiv" only after that
the sleep() function is terminated.
I don't know why.
Tnx.
PS: anyone have a sleep() function that works ?
M.