webguync Posted July 7, 2010 Share Posted July 7, 2010 Hi, I am looking to do something similar to the timer code below except, I don't want the user to have to press a button to get the alert, I want it to appear automatically after 1 hour (60 min). How would I alter the code to do this? <html> <head> <script type="text/javascript"> function timedMsg() { var t=setTimeout("alert('5 seconds!')",5000); } </script> </head> <body> <form> <input type="button" value="Display timed alertbox!" onClick="timedMsg()" /> </form> </body> </html> Link to comment https://forums.phpfreaks.com/topic/207024-setting-a-timer-alert/ Share on other sites More sharing options...
jug Posted July 7, 2010 Share Posted July 7, 2010 you want something like <html> <head> <script type="text/javascript"> function startTimer(){ var t = setTimeout("alert('5 seconds!')",5000); } </script> </head> <body onload="startTimer();"> //html here </body> </html> though edit it for 60 mins hope this helps Link to comment https://forums.phpfreaks.com/topic/207024-setting-a-timer-alert/#findComment-1082662 Share on other sites More sharing options...
webguync Posted July 7, 2010 Author Share Posted July 7, 2010 ok, thanks. Will give it a try. So for 60 minutes it will be.. function startTimer(){ var t = setTimeout("alert('1 Hour!')",3600000); } Link to comment https://forums.phpfreaks.com/topic/207024-setting-a-timer-alert/#findComment-1082667 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.