Book Section
-----
TY JavaScript 3rd Ed.
Teach Yourself JS 1.5
Teach Yourself DHTML
Teach Yourself JS 1.3
LLWW: JavaScript

General Section
-----
Discussion Forum
Articles / Tips
JavaScript Links
About the Author
Privacy Policy
Contact Me



Other Sites
-----
Website Workshop
JavaScript Weblog

JavaScript Workshop Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Can you call javascript from the "background-image"

 
Post new topic   Reply to topic    JSWorkshop Forum Index -> DHTML and CSS
View previous topic :: View next topic  
Author Message
jpainter
New member
New member


Joined: 22 Mar 2009
Posts: 1
Location: United States

PostPosted: Sun Mar 22, 2009 9:52 am    Post subject: Can you call javascript from the "background-image" Reply with quote

The main site page has a banner div with an attached #banner style. Within the div, a portrait photo floats to the far right hand side.

The "background-image" property of the #banner style currently points to scenery.jpg and displays the scenery photo nicely behind the portrait photo.

I have a java script module that will rotate photos for a slide show effect. It works perfectly in a "normal" call.

Is there a way to call this java script routine instead of the .jpg from the "background-image" property of the style?

The goal is to produce a layered effect with a rotating bottom layer. (True layers won't work, as then you lose the ability to center the main container div on the page.)

Can this be done?
Back to top
View user's profile Send private message
sohnee
Senior Member
Senior Member


Joined: 17 Jul 2002
Posts: 2077
Location: UK

PostPosted: Thu Apr 09, 2009 12:13 am    Post subject: Reply with quote

You can change the background image using DHTML - you'd be hard pressed to make a nice transition - just a swap...

Code:
document.getElementById("mydiv").style.backgroundImage = "another.jpg";

_________________
I also work on... Steve Fenton's Blog and contribute to The Enhance PHP Unit Testing Framework
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    JSWorkshop Forum Index -> DHTML and CSS All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group
(c) 1997-2002 Starling Technologies and Michael Moncur. Portions (c) Sams Publishing.