Hey Guys

What i want is, to show a pop up or a simple div or a modal or any dialogue box to to load on my home page to show welcome message, whats new etc stuff, which will be displayed only once in a day to every visitor of my site,(at the first visit of the day only ) But i want to load this modal after a sec when all the other elements of the pages have been finished loading.
I have seen this kind of thing on other websites but have no idea of how to do that, Any expert with related idea out there?

Thanks in advance.

Member Avatar for kiamzattu

The browser loads the java script when it encounters the script tag. So you can place the script tag after all the elements in the page is loaded.
<body>
your content
<script ..../>
</body>

But it is considered a good practice to place scripts in the head tag. So if you are not allowed to place it after the body tag, use the defer attribute in the script tag.
<script type="text/javascript" defer>
your script goes here
</script>
This effectively 'stops' loading the javascript until all the elements in the page are loaded. You can read more about 'defer' here

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.