Total members 11895 |It is currently Sat Dec 21, 2024 7:08 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





Automatic change to webpage background image using random function, changed every page new page-view.
javascript code
<html>
<head>
<title>Automatic change to webpage background image </title>

<!--
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
Note you can download the JQuery package instead of using Google version. -->
<script src="jquery-1.8.3.js"></script>
<script>
$(document).ready(function(){

var numberOfImages=3;

var imageNum = Math.round(Math.random()*(numberOfImages-1))+1;

var imgPath=('./'+imageNum+'.jpg');

$('body').css('background-image', ('url("'+imgPath+'")'));

});
</script>

</head>
<body>
<b> Page background image is changed randomly for every page view. </b>

</body>

</html>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Automatic change to webpage background image
 Move image in front of a background image     -  
 change background of the paragraph     -  
 change background color with RGB     -  
 Change the body tag background in html     -  
 Change background position when mouse over     -  
 No repeated background image     -  
 Repeat background image on y axis     -  
 Repeat background image on x axis     -  
 right bottom background image position     -  
 Set position of background image in pixels     -  



Topic Tags

JQuery Image






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com