javascripttech.blogspot.com
Using setTimeout to get back to the output we want.
HTML
<body>
<p id="result"></p>
</body>
JavaScript
document.getElementById('result').innerHTML += ('starting ...');
var myTimer = window.setTimeout(function() {
document.getElementById('result').innerHTML += ('ending!');
}, 300);
document.getElementById('result').innerHTML += ('continuing ...');