Link to home
Start Free TrialLog in
Avatar of LPNavon
LPNavonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Swap Background Image

Is it possible / advisable to swap background images as a disjointed rollover from another image?
Avatar of bdichiara
bdichiara
Flag of United States of America image

I don't quite understand. Are you trying to roll over 1 image and swap the background of another image?

////// javascript  ////
function swapBG(el,src){
    var elm = document.getElementById(el);
    elm.style.backgroundImage = 'url('+src+');';
}
 
 
////// html  ////
<div id="rollover" onmouseover="swapBG('main','myimage2.jpg');" onmouseout="swapBG('main','myimage1.jpg');"> roll over this text </div>
<div id="main" style="height:500px; background-image:url(myimage1.jpg);"> </div>

Open in new window

Avatar of LPNavon

ASKER

Yes I am rying to roll over 1 image and swap the background of another image...

But I'm not a coder so I was hoping to be hold how to do this using Dreamweaver's Behavior / Rollover or CSS  panels.

Thanks.
Unfortunately, I don't think Dreamweaver has a Swap Background Image behavior, only a rollover image behavior. If you're not willing to learn how to paste the code above into your code view, then I would suggest searching some of the Dreamweaver Plugins and Extensions to see if someone has written something like this. What you're asking for is quite specific and probably not a very common task, so I don't think there is much out there.

If you wanted to MODIFY the swap background image behavior, I could show you the modified code, however, if you went as far as doing that, might as well just use the code I gave you above.
Avatar of LPNavon

ASKER

Would you be able, without too much trouble, to instruct me as to how to insert that code and equate your generics to my specifics?
Thanks for your efforts.
ASKER CERTIFIED SOLUTION
Avatar of bdichiara
bdichiara
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LPNavon

ASKER

This looks very promising, with lots of pertinent instruction. I'll  try to get my head around it and give it a go. Thanks very much for the detailed effort.