buongiorno,
Ho un semplicissimo problema a cui non riesco trovare una soluzione:
Ho creato un div e tramite un temporizzatore ingrandirlo gradualmente. Il problema persiste nel .setAttribute, infatti in Chrome mi dà il seguente errore:
Uncaught TypeError: Object quadrato has no method 'setAttribute'
codice:
<html>
<head>
<script>
window.onload=setup;
var height=200;
var width=height;
function setup () {
quadrato=document.getElementById("quadrato");
setTimeout("ingrandisci('quadrato')",1000);
quadrato.setAttribute("height",height+"px");
quadrato.setAttribute("width",width+"px");
}
function ingrandisci (div) {
if (height <= 500) {
height+=40;
width=height;
//non funzionano e ho dovuto usare lo style interno al div
//lo so che è inusato, ma questo è solo uno schema
//riassuntivo di quello che devo fare
div.setAttribute("height",height+"px");
div.setAttribute("width",width+"px");
setTimeout("ingrandisci('div')",200);
}
}
</script>
</head>
<body>
<div id="quadrato" style="height:200px;width:200px;background-color:blue;" ></div>
</body>
</hmtl>