<body>
<script>
(function () {
var newImg = new Image();
newImg.src = 'http://javascript.ru/forum/image.php?u=19820&dateline=1334914235';
newImg.setAttribute('id', 'img');
document.body.appendChild(newImg);
})();
alert(document.getElementById('img').id)
</script>