Possible Duplicate:
setInterval - How to fire only once?
I would like to run the following code only once, so after 2 seconds it will change the iframe's src, but won't try to do it again and again.
<script type="text/javascript">
setInterval(function () {document.getElementById('iframe').src = "http://www.y.com";}, 2000);
</script>
You're looking for setTimeout()
, which does exactly that.