"Richard Speiss" wrote in message
news:%...
: I am trying to display a random background image for a webpage. I found
: this code to do it
:
: <%
: 'Defines the number of background images you have
: Const NUMBER_OF_IMAGES = 2
:
: 'Initiates the randomize function
: Randomize
:
: 'Sets a variable: this will be used to hold the
: 'random generated value
: Dim intImageNumber
:
: 'This is where we create the random number
: intImageNumber = Int((NUMBER_OF_IMAGES * Rnd) + 1)
: %>
:
:
: Modify the body tag to accept the random number. In this case we are going
: to place it within the image so as to facilitate the selection of a random
: image.
:
: <BODY BACKGROUND="bg_<%= intImageNumber %>.gif">
:
: This did work.
:
: In my case, I have an external style sheet with this defined:
:
: body {
: color:#333;
: background-color: gray;
: background-image: url(../images/bg_<%=intImageNumber%>.JPG);
: background-attachment: fixed;
: margin:20px;
: padding:0px;
: font:11px verdana, arial, helvetica, sans-serif;
: }
:
: and it is included in my main page with
:
: <head>
: <style type="text/css" media="screen">@import "css/cvs.asp";</style>
: </head>
:
: which comes after the above randomizing script
:
: I removed <BODY BACKGROUND="bg_<%= intImageNumber %>.gif"> from the main
: page and replaced it with just <body> thinking that since it is defined in
: the external CSS file I wouldn't need it on each page.
:
: I just got a gray background. Since I am really new to ASP and CSS I am
not
: sure the variables are global throughout included files or not. I wanted
to
: have the background image defined in the style file since it is used
: everywhere so rather than modiying <body> for each page I could have it in
: one place.
:
: Can this be done this way? Is there a better way to handle this
situation?
Remove the background-image line from your external CSS and just use it in
an onload.
<body onload="bg_<%= intImageNumber %>.gif">
Perhaps if your CSS was linked in prior to the script running and it was
..css instead of .asp, then perhaps the ASP processor would process that part
before rendering the page to the client. As it is now, and you can test by
loading the cvs.asp by itself and looking at the source, you'll see what is
actually being returned.
--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center -
http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation -
http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library -
http://msdn.microsoft.com/library/default.asp