Load Javascript Alert while the page is loading

0

Im wondering if its possible to load a JavaScript alert before the content while the page is loading

Whatever I try to do the alert fires and the page doesn’t load until the alert is closed

    <script>
alert('But wait, there\'s more...');
</script>

Well, you can use a page-listener to do this. Something like this should work:

<head>
<script type="text/javascript">
document.onreadystatechange = function() {
    if(document.readyState=='loaded' || document.readyState=='complete')
        alert('But wait, there\'s more...');
}
</script>
</head>

Or, if you are using Bootstrap on your site, you could use a modal pop-out which would work too.
If you want to do that, here is a site that shows how to do that: Bootstrap-Modal on page-load

Sponsor our Newsletter | Privacy Policy | Terms of Service