Jump to content
Sign in to follow this  
Major Fubar

Quick html/web-page question

Recommended Posts

OK, a very quick question for you HTML wizards out there...

How do I set up a web page so that it selects a random background pic each time it is loaded/refreshed...I will have about 4 to 6 images I wish to randomly select from uploaded to my web server.

Thanks, Fubar

Share this post


Link to post
Share on other sites

I think that that is beyond the scope of HTML...

So you need JavaScript, CGI or PHP or so on..

I know how to do it with CGI but maybe someone with

JS experiences will have easier solution.. smile.gif

Share this post


Link to post
Share on other sites

Hmm, maybe I could create a flash animation of the pics I want to use...can you set flash animations as backgrounds?

edit: maybe a gif would be simpler...

Share this post


Link to post
Share on other sites

HTML can not incorparate that sort of movement, your going to have to know some java to do that.

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (Rob @ Sep. 04 2002,17:05)</td></tr><tr><td id="QUOTE">your going to have to know some java to do that.<span id='postcolor'>

I dont think Java is going to help in that, unless MF wants to make his whole page one large Java applet...

You cannot have flash backgrounds, and with GIF you really cant have any randomness.

Only ways of doing it is with Javascript on the "client side" or with CGI/PHP/ASP/whatever on the server side. If you server supports any of those, a server side approach is much better as its totally invisible to the browser and thus always working the same way regardless of the browser.

Share this post


Link to post
Share on other sites

Thanks for the suggestions guys...I think the easiest will be to save the pics as an animated GIF. Not random, but at least it will cycle through the pics...

Share this post


Link to post
Share on other sites

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE">

<script>

/*Random Background Image-

By JavaScript Kit (www.javascriptkit.com)

More free JavaScripts here!

*/

var backgr1="../clip/backgr4.jpg"

var backgr2="../clip/backgr17.jpg"

var backgr3="../clip/backgr13.jpg"

var cur=Math.round(6*Math.random())

if (cur<=1)

backgr=backgr1

else if (cur<=4)

backgr=backgr2

else

backgr=backgr3

document.write('<body background="'+backgr+'" bgcolor="#FFFFFF">'wink.gif

</script>

<span id='postcolor'>

//EDIT found a better script for you.

Instead of the three: "var backgr1="../clip/backgr4.jpg"" Just type in the destination of your jpeg or gif file, for example:

var backgr1="background1.jpg"

//Edit 2

You need to put the script under the "Body" tag (<BODY>script here</BODY>)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×