newbie
newbie

Reputation: 29

How to pop up some contents before page load javascript

I have a script that invoke pageLoad after all content is loaded.

I need it to be on before page load

my script is

 function pageLoad()
{
    $('#myModal1').modal('show');
}

window.onload = pageLoad;

Can anyone do anything this script to get show on before load page?

Thanks very much

Upvotes: 0

Views: 3350

Answers (1)

rejo
rejo

Reputation: 3350

The onreadystatechange event is fired on a HTML document when the load state of the page's content has changed.

document.onreadystatechange = function()
{
    console.log(document.readyState);
    if (document.readyState === 'complete')
    {
        console.log("onbefore")
    }
};
window.onload = function(e)
{
  console.log("onload");
};

Upvotes: 2

Related Questions