我想实现JavaScript页面加载Impresspages 4.2.3上的背景图像更换器,如http://www.9lessons.info/2011/03/background-image-change-on-refresh-with.html所述。它在我的本地主机上工作,但移到我的托管服务器时不起作用。JavaScript背景图片在页面加载更改Impresspage
我把这段代码下面的“_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>
和下面这段代码在标签:
你忘了切换到这个路径:'document.body.background ='http://localhost/halmaheradivecruise.com/theme/air/assets/img/'+num+'.jpg';'到路径您的服务器上的图像? – DrewT 2014-10-07 04:58:06
我将路径更改为www。但仍然无法正常工作...... – user3766934 2014-10-07 05:03:48
为什么脚本中包含'标记? – DrewT 2014-10-07 05:20:45