The following is a JavaScript function that changes/rotates title of webpage automatically in every specified number of seconds.
In the function, we use the setTimeout() JavaScript method to execute the change title function after a specified time-interval, every 1 second in this example.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <script language="javascript"> function rotate_title(onoff, delay) { var title1 = "4 Rapid Development"; var title2 = "Website for developers, designers and webmaster"; var title = ""; var index = onoff; if(index == 0) { title = title1; index = 1; } else if(index == 1) { title = title2; index = 0; } document.title=title; timer=window.setTimeout("rotate_title("+index+"," + delay + ")",delay); } rotate_title(0,1000); </script> </body> </html> |
+ [download id=”11″ format=”1″]
+ See how it works, just focus on the page title.