Prova questo ad esempio. Fa uso dell'innerHTML che non e' DOM ma e' ben supportato
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
function Oggetto(width, height) {
this.container = document.createElement('div');
this.div = document.createElement('div');
this.div.style.width = width + "px";
this.div.style.height = height + "px";
this.div.style.backgroundColor = "#cccccc";
this.container.appendChild(this.div);
}
Oggetto.prototype.toString = function()
{
return this.container.innerHTML;
}
</script>
</head>
<body>
<div id="qui">
<script>
document.writeln(new Oggetto(100,100));
</script>
</div>
</body>
</html>