PHP Wait then Generate a Tag or Link

Generate the following HTML:

<script type="text/javascript">
    function handleTime() {
        var time = parseInt(document.getElementById('time'));
        function finish() {
            document.getElementById("container").innerHTML = '<a href="https://stackoverflow.com/questions/49852073/php-wait-then-generate-a-tag-or-link">Some link</a>';
        }
        if (time === 0) {
            finish();
        } else {
            var myInterval = setInterval(function() {
                if (!(--time)) {
                    clearInterval(myInterval);
                    finish();
                }
            }, 1000);
        }
    }
</script>

<div id="container" onload="handleTime()">
    <span id="timer">Link will generated After </span><span id="time">10</span> Seconds</span>
</div>

This will get the number of seconds into a variable and decrease it in each second until it reaches 0. When it reaches 0, your link will be generated into the HTML.

Leave a Comment