Welcome to YLOAN.COM
yloan.com » Internet » Timing events in Javascript
Games Personal-Tech Data Entry registry cruise torrent mac code virus storage uninstaller systems cisco bugs wireless codes maintenance dell update communication trojan atlanta Data Backup Data Storage Data Protection Data Recovery Anti-Virus Windows Linux Software Hardware Mobil-Computing Certification-Tests Computers & Internet Internet

Timing events in Javascript

Timing events in Javascript

Timing events in Javascript

We all know sites that refresh themselves (sometimes even before we finished reading what we were reading). Usually, the types of sites that need to be refreshed are sites with pages that changes frequently like news sites.

If you ever asked yourself how they do it, then the answer is quite simple and we are here to answer it: using Javascript code.

The truth is that the easiest way to schedule page to be refreshed is actually not using Javascript, but using one script line in HTML that looks like this:

This line should be places in the section of our HTML document and it will cause the page to be refreshed every 15 seconds.Of course you can change the refresh time as needed. For example if we want the page to be refreshed every 2 minutes our code will look like this:

You are probably wondering if it's so easily done in HTML then why you should know how to schedule events in Javascript?

The answer is quite simple: because sometimes we need to change parts of our page on client side, so we don't want to cause the entire page to go all the wayto the server and back. For example suppose we want to display an on-screen clock with seconds hand which

is in constant motion. Or we want to write a presentation of images in which images are changing automatically every few seconds. In the following example will create a Javascript function that will refresh a page 5 seconds after the function is called.

You can of course call it from a link or a button or in any other way that is appropriate for you. You can also call another function from within the refreshing function.

Sample code for scheduled page refresh event:

RefreshPage function ()

{

var t = setTimeout ("refresh ()", 5000);

}

The SetTimeout function takes two values:

1) The name of the function we want our function to call.

2) The time interval for calling the function from our function

Time will always be in milliseconds, which means that every second is worth 1000 milliseconds. The called function can be one of JavaScript's built in functions or a function you wrote yourself.

This code will work also within a frame, so even if you put your page within a frame you can still use it.
Three Simple Secrets To Internet Marketing Success How to Secure Your Wireless Network: 101 Why It Is Helpful To Start An Internet Based Home Business! Can Social Networking Affect Your Credit Rating With The Bank? T-Pain Rap Song Ringtone | Download T-Pain Rap Song Ringtone Straight To Your Phone Rihanna What's My Name Ringtone | Download Rihanna What's My Name Ringtone Straight To Your Phone Booking Last Minute Hotels – Internet is the Key to the Best Hotel Deals at the Last Minute Kanye West Monster Ringtone | Download Kanye West Monster Ringtone Direct To Your Phone Seniors and Networking Keep a look TV Web stores internet With Free Web TV Bank of Beijing, networking equipment items and taxation Library Tender Notice - Network products, bidding-IT industry Dish Network : For Both Work And Play Test Your Internet Marketing Skills
print
www.yloan.com guest:  register | login | search IP(216.73.216.170) California / Anaheim Processed in 0.017277 second(s), 7 queries , Gzip enabled , discuz 5.5 through PHP 8.3.9 , debug code: 37 , 2409, 49,
Timing events in Javascript Anaheim