Edit in JSFiddle

var boje = ['red', 'green', 'blue', 'yellow', 'violet', 'pink', 'grey'];
setInterval(function(){
    document.body.bgColor = boje[ Math.floor(Math.random() * 6) ] 
    }, 3000);
<h1>Jednostavna smena boja</h1>
body{
    font-family:Arial;
    text-align:center;
    color:#fff;
    transition: all 0.3s linear 0s;
    text-shadow:1px 1px 10px rgba(0,0,0,.3);
}