Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Old 03-04-2006, 06:18 PM 2 Images on Rollover
Cambridge's Avatar
Experienced Talker

Posts: 46
Trades: 0
Hi! I am wondering how to get 2 images instead of 1 on one hover button.

Example:
_______
|button | <I HOVER OVER THIS THE BUTTON CHANGES TO A DIFFERENT IMAGE
| 1 | BUT IT ALSO CHANGES THE IMAGE SOMEWHERE ELSE
----------

i put another blank transp. gif on another spot on
the page and when i hover over button 1 theirs a
different image when i hover over this.

so what im trying to say is how do i get a button to hover normally, but have another image change somewhere else at the same time.
Cambridge is offline
Reply With Quote
View Public Profile Visit Cambridge's homepage!
 
 
Register now for full access!
Old 03-04-2006, 07:48 PM Re: 2 Images on Rollover
Unknown.

Posts: 1,693
Trades: 0
Javascript can do the trick, by changing the source of the images, like so..
HTML Code:
<script type="text/javascript">
function change() {
document.getElementById('button').src = "whatever.gif";
document.getElementById('otherone').src = "whatever.gif";
}
</script>

<img src="button.gif" alt="" id="button" onmouseover="change();" />
<img src="whatever.gif" alt="" id="otherone" />

Last edited by Dark-Skys99; 03-04-2006 at 07:50 PM..
Dark-Skys99 is offline
Reply With Quote
View Public Profile
 
Old 03-05-2006, 01:17 AM Re: 2 Images on Rollover
Super Talker

Posts: 144
Trades: 0
Quote:
Originally Posted by Dark-Skys99
Javascript can do the trick, by changing the source of the images, like so..
HTML Code:
<script type="text/javascript">
function change() {
document.getElementById('button').src = "whatever.gif";
document.getElementById('otherone').src = "whatever.gif";
}
</script>
 
<img src="button.gif" alt="" id="button" onmouseover="change();" />
<img src="whatever.gif" alt="" id="otherone" />
cool, but I would say to use the 'images' collection. that's what it is there for. kill the 'id' or keep it, but give the images a 'name' attribute as is standard.

refer to like so, document.images.imageName.src / document.images["image_name"].src

and it's always best to pre-load the images before hand, otherwise, there is a download time upon rollover, before the images are displayed.

var pre_loaded_image = new Image();
pre_loaded_image.src = "images/my_image.jpg";

document.images.myImage.src = pre_loaded_image.src;

walla.
__________________
create.vibe

Please login or register to view this content. Registration is FREE
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Old 03-05-2006, 02:19 AM Re: 2 Images on Rollover
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
or you can just use CSS Rollovers
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-05-2006, 06:02 PM Re: 2 Images on Rollover
Extreme Talker

Posts: 170
Location: Canada
Trades: 0
Chrishirst has the right idea but I've found that using images in the background of some CSS elements have limited browser compatibility. You're better off using some old school javascripts until the release of the next generation browsers.
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
collyer_1 is offline
Reply With Quote
View Public Profile Visit collyer_1's homepage!
 
Old 03-07-2006, 09:14 AM Re: 2 Images on Rollover
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
The best x-browser solution I've used is with CSS. The basic strat is to change the <a> to display: block; and give it the same pixel dimensions as the image roll over. Both states of the roll-over are included in the one image file which makes the image 2x the width of the <a> block. The rest state for the link gets the background image aligned right, and the hover state gets the background image aligned left. You get the idea....

Has been tested in IE FF NN Opera, Safari and a host of others - no issues.
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 03-08-2006, 08:14 AM Re: 2 Images on Rollover
Super Talker

Posts: 102
Trades: 0
Something I've been wondering. When you use the pure css solution for image rollovers especially with somewhat larger images, there is this split second in the browser where you can obviously see it switching images. In IE there's even a black background. This looks kinda buggy and was wondering is there's any way to prevent that from happening.

I understand that this is no issue for the JavaScript solution as the images get preloaded in that manner.
ghettobert is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to 2 Images on Rollover
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.19088 seconds with 12 queries