Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

choosing background from multiple images

Status
Not open for further replies.

brisray

Programmer
Feb 7, 2002
88
US
I've got an array of images. I put them on the page fine. When clicked on the image calls a function to change the page background that image. The funtion is entered correctly (I can get the varibles from within the function) and it works in Netscape v7.1 and Mozilla 1.4 but NOT IE v6 or Opera v7.11

The function is really simple ...

<script language=&quot;JavaScript&quot;>
function ChngBGImg(imgnum){
document.body.background=bgimgarray
;
}
</script>

Does anyone have anything similar that will work in all the above browsers or failing that, can work in IE or Opera.

You can see that this is part of a larger project.
Ray
 
Oops, sorry.

I didn't stop to read what I had typed. I hope this one works...

Code:
document.body.style.background-image='url('+bgimgarray[img]um[/img]+')';

Now, if I check one of my scripts and find it's different I'm going to feel remarkably stupid! :D

I'm willing to trade custom scripts...
 
Dammit, dammit! :'(

document.body.style.backgroundImage='url('+bgimgarray
+')';


I'm willing to trade custom scripts...
 
wow - thanks for that stormblind. I only just came back to say I've just worked it out. I used ...

document.body.style.backgroundImage = &quot;url(\&quot;&quot; + bgimgarray
+ &quot;\&quot;)&quot;;

Visit anyway, just to see what I'm trying to do.

Ray
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top