admin管理员组文章数量:1356778
I want to do the below with pure JavaScript if it is possible (or jQuery)
- the page is fully loaded.
- wait 5 seconds.
- alert('msg') once with no setInterval loops.
I want to do the below with pure JavaScript if it is possible (or jQuery)
- the page is fully loaded.
- wait 5 seconds.
- alert('msg') once with no setInterval loops.
- 2 The downvotes are a result of lack of research effort as this shouldn't be hard to research yourself and at least e up with a code attempt – charlietfl Commented Apr 26, 2015 at 14:52
3 Answers
Reset to default 3Try setTimeout
:
document.onload = setTimeout(function () { alert('msg'); }, 5000);
jQuery solution:
$(document).ready(function()
{
setTimeout(function()
{
alert('msg');
},
5000);
});
<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
Use setTimeout
, not setInterval
. I kept the answer as verbose as the question.
Try this:
$(document).ready(function(){
setTimeout(function(){ alert("msg");}, 5000)
})
do not forget put jquery reference to your html header:
<script src="http://code.jquery./jquery-2.1.3.min.js"></script>
本文标签: javascriptalert msg once5 seconds after the page loadedStack Overflow
版权声明:本文标题:javascript - alert msg once, 5 seconds after the page loaded - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743958358a2568553.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论