Salve ragazzi . . .
ho il seguente script per cambiare il colore di sfondo del mio sito web ogni 60 sec.
codice:
<scripttype="text/javascript">
//
// Description: Randomly change background color every 60 seconds
//
// NewcWare 1997
// Author: Scott Newcomer 3/1997
// Email: nuke@bright.net
//
function setbackground()
{
window.setTimeout("setbackground()",60000);// 60000 milliseconds delay
var index =Math.round(Math.random()*4);
varColorValue="FFFFFF";// default color - white (index = 0)
if(index ==1)
ColorValue="DEC7FF";//lt violet
if(index ==2)
ColorValue="CAD5FF";//lt blue
if(index ==3)
ColorValue="E4FFB1";//lt green
if(index ==4)
ColorValue="DDDDDD";//lt grey
document.getElementsByTagName("body")[0].style.backgroundColor ="#"+ColorValue;
}
</script><bodyonload="setbackground();">
Volevo che lo script non funzionasse se si visita il mio sito da smartphone e ho modificato la stringa
codice:
document.getElementsByTagName("body")[0].style.backgroundColor ="#"+ColorValue;
in
codice:
if(!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent))){
document.getElementsByTagName("body")[0].style.backgroundColor ="#"+ColorValue;
ma niente, non funziona . . .
Qualcuno saprebbe aiutarmi?