Lukela Posted January 12, 2008 Share Posted January 12, 2008 Here's my situation, Im building a Browser-based game. In this games you have these troops that you are able to attack people's villages and such, when you attack someone you need to take the time difference between them two and that will be how long it takes to reach the target. I can use PHP to calculate the time, but I need a JS script that once the time hits 00:00:00 it would run the attack script to calculate the battle. Anyone here can help? Quote Link to comment Share on other sites More sharing options...
jos. Posted January 12, 2008 Share Posted January 12, 2008 setTimeout('your_Attack_function',5000); the 5000 is milliseconds. Jos. Quote Link to comment Share on other sites More sharing options...
Lukela Posted January 12, 2008 Author Share Posted January 12, 2008 Am I able to leave the webpage while the time is calculating? Quote Link to comment Share on other sites More sharing options...
jos. Posted January 12, 2008 Share Posted January 12, 2008 not directly no. a jS script will only continue to run whilst the page the script is embedded in is loaded in the browser window. this does not mean that the script would die if you were to utilize an <iframe> to display another page within the current page. Hope to have helped. Jos. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.