make the screen flash by changing its background color via body.style.backgroundColor - Javascript CSS Style Property

Javascript examples for CSS Style Property:backgroundColor

Description

make the screen flash by changing its background color via body.style.backgroundColor

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript">
    window.onload=( function() {/*from   w  ww .  ja v  a  2 s  .  c om*/
window.flash = function() {
 if(flashStep==1) {
 document.body.style.backgroundColor="#FFFF00";
 flashStep=2;
 }
 else {
 document.body.style.backgroundColor="#FF0000";
 flashStep=1;
 }
}
var flashStep = 1;
var task = window.setInterval(flash,1000);
    });

      </script> 
   </head> 
   <body> 
      Hi  
   </body>
</html>

Related Tutorials