Click to See Complete Forum and Search --> : Change background image with JS
kierhon
02-08-2008, 05:54 PM
I have two seperate divs that i want the content to be controlled by this slider http://www.dynamicdrive.com/dynamicindex17/featuredcontentslider.htm
How could i add to this existing code to change the background image of a completely seperate div while is scrolls through?
JMRKER
02-09-2008, 07:37 AM
Do you have more information about what you want to do?
Do you have any starting attempts that don't work?
While this: http://www.nova.edu/optometry/pharmacy/old/TimedBtn.html
doesn't use the link in post #1 you might be able to get some ideas by seeing how combining it with this next link might provide the same functionality: http://www.nova.edu/optometry/pharmacy/old/Carousel.html
Some other examples can be found at: http://www.nova.edu/optometry/pharmacy/old/index.html
Should be easy enough to blank out the text display portions if you
don't want that function.
kierhon
02-11-2008, 01:39 PM
http://207.179.75.89/spartanstatic/sumitomo/forestry.php
This is what i've got so far. I'd like the banner image (which is currently a background image in the css) to change as the slider changes. I just can't quite wrap my mind around how i would go about this..
Your links and resources did help, i'm just not sure how to implement them without heavily changing my existing structure.
Is it possible to change a css property of a div with javascript each time. Maybe getElement and then pass a new bkgd property with each slide..?
nap0leon
02-11-2008, 03:38 PM
document.getElementById('bannerID').style.backgroundImage = 'url(newimage.gif)'
kierhon
02-11-2008, 04:39 PM
How would i pass the background color to be a variable based off an attribute such as <img src="images/image.jpg" rel="url(images/anotherimage.gif)" />
ContentSlider.autoturnpage=function(sliderid, autorunperiod, bkgd){
var bkgd=document.getElementById('page_banner').style.backgroundImage = 'url(images/image.gif)'
var paginatelinks=document.getElementById("paginate-"+sliderid).getElementsByTagName("a") //Get pagination links
var nextpagenumber=parseInt(paginatelinks[paginatelinks.length-1].getAttribute("rel")) //Get page number of next DIV to show
ContentSlider.turnpage(sliderid, nextpagenumber) //Show that DIV
window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod, bkgd)}, autorunperiod)
}