我想按照http://www.9lessons.info/2011/03/background-image-change-on-refresh-with.html中的描述在 Impresspages 4.2.3 上的页面加载上实现 javascript 背景图像转换器。它适用于我的本地主机,但在移动到我的托管服务器时不起作用。
我把这段代码放在标签之间的“_header.php”下面:
<script type="text/javascript">
var totalCount = 4;
function ChangeIt()
{
var num = Math.ceil( Math.random() * totalCount );
document.body.background = 'http://localhost/halmaheradivecruise.com/theme/air/assets/img/'+num+'.jpg';
document.body.style.backgroundRepeat = "repeat";// Background repeat
}
</script>
并且下面的代码在标签中:
<script type="text/javascript">
ChangeIt();
</script>