/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] random page wallpaper

sorry, shoulda read some before posting, mods feel free to delete this ^^;

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Eyes_OnlyauthorJan 31.2009 — allright, they didnt answer my question in the other post so ill post it here... i need a way of cycling the background of a web page each time the page is loaded. all of the images are of the same format and in the same directory. there are 67 images. perhaps someone can help and modify a script or create one similar to this?
[CODE]<script type="text/javascript" language="JavaScript">
<!-- Copyright 2002 Bontrager Connection, LLC
//
// Type the number of images you are rotating.

NumberOfImagesToRotate = 67;

// Specify the first and last part of the image tag.

FirstPart = '<img src="wall';
LastPart = '.jpg" height="1600" width="1200">';

function printImage() {
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
document.write(FirstPart + r + LastPart);
}
//-->
</script>[/CODE]
Copy linkTweet thisAlerts:
@astupidnameJan 31.2009 — change the 'wall' and/or '.jpg' to suit, as well as NumberOfImagesToRotate, and then 'someId' is an id of element on page (change to suit):

[CODE]<script type="text/javascript">

window.onload = function () {
var NumberOfImagesToRotate = 67;
var r = Math.ceil(Math.random() * NumberOfImagesToRotate);
var image = 'url(wall' + r + '.jpg)';
document.getElementById('someId').style.background = image;
};

</script>[/CODE]
Copy linkTweet thisAlerts:
@Eyes_OnlyauthorFeb 01.2009 — thank you :]
×

Success!

Help @Eyes_Only spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.22,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...