我正在尝试获取随机背景图像。但是当我加载页面时,我的背景是空的。这是我的代码:
<html>
<head>
<script>
function random_imglink(){
var myimages=new Array();
myimages[1]="images/1.png";
myimages[2]="images/2.png";
myimages[3]="images/3.png";
myimages[4]="images/4.png";
var count=Math.floor(Math.random() * myimages.length);
if (count==0){
count=1;
}
document.write("'" + myimages[count] + "'");
}
</script>
<link rel="stylesheet" type="text/css" href="styles.css" />
</head>
<body background=random_imglink()>
<?php include ("header.php"); ?>
<div align="center" >
<?php include ("main.php"); ?>
<?php include ("footer.php"); ?>
</div>
</body>
</html>
我希望有人能解决这个问题?