Adding Content to a Randomized Background

Posted by user2903815 on Stack Overflow See other posts from Stack Overflow or by user2903815
Published on 2013-10-21T15:43:49Z Indexed on 2013/10/21 15:53 UTC
Read the original article Hit count: 141

On refresh my background image changes. I need to add a header to change with each background. How would I add an h1 tag to the php. I am unfamiliar with php but I feel like this should be an easy fix.

Here's my script:

<script type="text/javascript"> 
var bgcount = 3;
function changebg() {
var num =  Math.ceil( Math.random() * bgcount );
document.body.background = 'bgs/'+num+'.jpg';
document.body.style.backgroundRepeat = "no-repeat";
document.body.style.backgroundAttachment = "fixed";
document.body.style.backgroundSize = "cover";
}
</script>

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about background-image