0
이미지를 표시하는 PHP 스크립트가 있고 (현재 시간에 따라) 이미지를 깜박 거리기 때문에 스크립트를 추가하려고했으나 작동하지 않는 것이 있습니다. 한번 봐주세요. 나는 당신의 도움에 감사 할 것입니다. 미리 감사드립니다.이미지가 깜박이지 않습니다.
<!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 onload="startit();">
<?php
$hour = date('H', time()); // Returns the hours of the server time, from 0 to 23.
switch ($hour) {
case '0':
$img = '0.jpg';
break;
case '1':
$img = '0.jpg';
break;
// ... and so on...
default:
$img = '1.jpg';
}
?>
<img src="<?php echo $img; ?>" id="mydiv" />
<script language=javascript>
/*This script written by Chris Stahl*/
/*It may be used and modified by */
/*webmaster's for private use. */
function startit() {
window.setInterval("changecolor()",100);
}
function changecolor() {
var rndred=Math.floor(256*Math.random());
var rndgreen=Math.floor(256*Math.random());
var rndblue=Math.floor(256*Math.random());
var colorarray=[rndred, rndgreen, rndblue];
var hexcolor="#";
for(i=0;i<3;i++) {
hexcolor=hexcolor +""+ converttohex(Math.floor(colorarray[i]/16));
hexcolor=hexcolor +""+ converttohex(colorarray[i]%16);
}
document.getElementById("mydiv").style.color=hexcolor;
}
function converttohex(num) {
switch (num) {
case 10: return "A";
case 11: return "B";
case 12: return "C";
case 13: return "D";
case 14: return "E";
case 15: return "F";
default: return num;
}
}
</script>
</body>
</html>
는'style.color' 단지 문제의 요소의 배경 색상에 영향을주지 않습니다 작동합니까? 그것은 어떤 CSS를 한 이후로 꽤 오랜 시간이 걸렸지 만 그것이 작동하는 것을 기억하는 방법입니다. 나는 그것이 이미지에 어떤 영향을 미치지 않을 것이라고 생각합니다. – Ilion