2012-04-02 69 views
-4

我想显示消息“你好吗?” 1分钟使用[JavaScript] [1]。 1分钟后,我希望它消失。你能帮我写代码来产生这个吗?Javascript时间事件

编辑:我曾尝试这样的代码:

下面是我TRID代码...

<html> 
<head> 
<script type="text/javascript"> 
function timeMsg() 
{ 
    var t=setTimeout("alertMsg()",3000); 
} 
function alertMsg() 
{ 
    document.write("Hellow"); 
} 
</script> 
</head> 
<body> 
<form> <input type="button" value="Display alert box in 3 seconds" onclick="timeMsg()"/> 
</form> 
</body> 
</html> 
+0

https://developer.mozilla.org/en/DOM/window.setTimeout – 2012-04-02 15:56:49

+4

[你尝试过什么?](http://mattgemmell.com/2008/12/08/what-have-you-tried/) – j08691 2012-04-02 15:59:00

+0

在javascript中检查'setTimeout'方法以帮助原因..当您发布问题时,请解释步骤如果可能的话,你已经采取了一些你已经尝试过的代码,并避免一般问题。在发布问题之前,请参阅[FAQ](http://stackoverflow.com/faq)。 – optimusprime619 2012-04-02 16:00:19

回答

1
setTimeout(function() { 
    /* hide message logic */ 
}, 60000); 
+0

以下是,我TRID代码... <脚本类型= “文本/ JavaScript的”> 功能timeMsg() { 变种T = setTimeout的( “ALERTMSG()”,3000); } function alertMsg() { document.write(“Hellow”); }

< 的onclick = “timeMsg()”/ INPUT TYPE = “按钮” 值= “3秒显示警告框”> – 2012-04-03 15:26:02

0

使用方法的setTimeout:

setTimeout(function() { 
// hide your message 
}, 60000); 
0

因为我认为它不够jQuery在那些其他的答案,这是我的!

jQuery(window).delay(6e+4).show(function() { 
    /* hide message logic */ 
}); 

我曳当然,.setTimeout会做得很好