News Ticker

Using javascript-change background image on page refresh

By Ajay Verma - Friday 13 November 2015 No Comments
Hello friends, one user asked me to provide some code for his wordpress website to change background image on page refresh.
i have write several code and tested on my own localhost wordpress website, they are working fine for normal webpages but not worked for Wordpress due to some css problem. finally i solved by modified javascript code which is given below:

<script type="text/Javascript">
var unknowndevice64_Count = 3; // no of background image you want to add ;)
function unknowndevice64_doit() {
var num = Math.ceil( Math.random() * unknowndevice64_Count );
if(num==1) {
document.write('<style type="text/css">body {background-image: url(;}<\/style>');
} else if(num==2) {
document.write('<style type="text/css">body {background-image: url(;}<\/style>');
} else {
document.write('<style type="text/css">body {background-image: url(;}<\/style>');
} } </script>
<script type="text/javascript">

** do not add any other background image in body.
you can also use below lines for normal webpage:
document.body.background = '';
in replacement of adding bg image by style.
Hope you will like this code.. :)
for any other help or code you can write to me. :)

No Comment to " Using javascript-change background image on page refresh "