/    Sign up×
Community /Pin to ProfileBookmark

BG change to tiled image on rollover

I’m looking for code:
I have pre-made web pages with 10 images (inside tables) on each. I’m seeking code that will change the background to a tiled display of each image as it is rolled over.

Thanks much

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@JonaJun 01.2004 — [font=arial]Hello Lupatrian,

Try using the following in your head tag.[/font]

<i>
</i>&lt;script type="text/javascript"&gt;
function changeBgImg(src)
{
document.body.style.backgroundImage = src;
}
&lt;/script&gt;


[font=arial]And then use this on your image links.[/font]

<i>
</i>&lt;a href="noJS.html" onclick="changeBgImg('images/image.jpg'); return false;"&gt;&lt;img src="images/image.jpg" alt="Background image"&gt;&lt;/a&gt;


[font=arial]Be sure to change "images/image.jpg" to the SRC of your image.[/font]
Copy linkTweet thisAlerts:
@fredmvJun 02.2004 — [i]Originally posted by Jona [/i]

[B]document.body.style.backgroundImage = src;[/B][/QUOTE]
Would not work. Since a background image is defined like this in CSS:background-image: url(foo.png);You must also use the same notation in JavaScript, thus:document.body.style.backgroundImage = 'url(' + src + ')';
Copy linkTweet thisAlerts:
@JonaJun 02.2004 — [font=arial]Haha, my bad, Fred. Forgot. ? [/font]
Copy linkTweet thisAlerts:
@fredmvJun 02.2004 — No problem man. I've made that exact same mistake myself a few times, so it's easier for me to catch. ?
×

Success!

Help @lupatrian spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...