navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

Pre-load images using CSS (such as hover images)

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Community >> OutFront Discoveries >> Pre-load images using CSS (such as hover images)
Page: [1]
 
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
Pre-load images using CSS (such as hover images) - 3/5/2006 2:36:38   
It's been rather annoying when I would rollover a menu image (in a list), and watch it disappear and then reappear with the new rollover image.

I searched for awhile for a javascript solution to this, but didn't find anything that was simple to do.

After thinking for awhile I figured I could just create a div and have it load the image, and display nothing.

I've only tested it locally, so I am not sure if it works with all browsers, but there shouldn't be a reason it wouldn't.

First, create a div id in your CSS file that uses the background attribute to display the image, then set the div to not display anything.

div#preload1 {background: url(images/menu2.gif);display:none;}
div#preload2 {background: url(images/subnav2.gif);display:none;}


Then go to your HTML page where the image is going to display, and insert the div with the id specified above somewhere in the HTML (placement doesn't really matter).

<div id="preload1"></div><div id="preload2"></div>


If anyone knows of a valid way to condense it into one line, speak up.

[edit]It looks like this would be a better way of doing what I want: Sliding Doors of CSS, Part II[/edit]

< Message edited by BobbyDouglas -- 3/5/2006 5:48:07 >


_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge
d a v e

 

Posts: 4170
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 2:42:53   
a quick google for css preload found a few things that might be more condensed

in particular one on zeldman
http://www.zeldman.com/daily/0203c.shtml (scroll down or search in your browser for "preload")
:)

_____________________________

David Prescott
Gekko web design

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 3:47:37   
Google's results were pretty horrible, at least the 1st page ones- I didn't bother checking the other pages.

Looking at that code, you still need to include the div in the page for the browser to reference the image, right?

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to d a v e)
d a v e

 

Posts: 4170
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 4:02:48   
think so...


_____________________________

David Prescott
Gekko web design

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 4:12:21   
Basically what I meant was that you will end up with the same code as what I have.

Although I did learn how to block people from viewing your CSS file!

Try finding the CSS file for http://www.maratz.com if you don't manually change the referrer, you won't be able to get it!!!!!

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to d a v e)
d a v e

 

Posts: 4170
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 4:15:34   
yep.

not sure how to manually change the referrer but do you mean this stylesheet?
http://members.tiscali.fi/dave_pirjo/test-area/maratz.css


_____________________________

David Prescott
Gekko web design

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 4:22:53   
quote:

ORIGINAL: d a v e

yep.

not sure how to manually change the referrer but do you mean this stylesheet?
http://members.tiscali.fi/dave_pirjo/test-area/maratz.css


- Yup, that's the one I found. However, I changed my referrer to see his cool script in action and was actually able to see the file load! :)

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to d a v e)
spitfire

 

Posts: 424
Joined: 8/6/2005
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:19:54   
Or, using Firefox Developer Toolbar - css > view css > select http://www.maratz.com/css/masta_file/ = other interesting goodies including the site's erm... hidden css file. :)

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:35:57   
When I do that it says:
"CSS - http://www.maratz.com/css/masta_file/
http://www.maratz.com/css/masta_file/"

What didn't I do that you did to get the CSS to display?

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to spitfire)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:46:54   
Here is a much better way to accomplish what I want in the OP: Sliding Doors of CSS, Part II

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to BobbyDouglas)
spitfire

 

Posts: 424
Joined: 8/6/2005
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:48:22   
When I selected http://www.maratz.com/css/masta_file/ this screen came up
quote:

/*
Thanks for showing interest!
Related articles you might be interested in:
Comment Preview Script
Scrolling Drop Shadows
Hidden CSS
This site's CSS file
*/

Then, in a massive leap of faith, I clicked on This site's CSS file:)

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5470
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:52:21   
That's might be the code in the CSS file that is used, but that is most likely not the exact same file that is being called!

Cheater!

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to spitfire)
spitfire

 

Posts: 424
Joined: 8/6/2005
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 3/5/2006 5:59:18   
Care to highlight the differences from the version YOU found?
Bluffer! :)

(in reply to BobbyDouglas)
johnwboyd

 

Posts: 1
Joined: 7/5/2008
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 7/5/2008 11:16:03   
Another option I just did that worked like a charm is to to simply code the image(s) and set their height and width to 0. : ) So the browser loads the hover with the page load without any complicated scripts or even div's needed. And a very small bg image is NOT going to slow page load down. : )

(in reply to BobbyDouglas)
jaybee

 

Posts: 14191
Joined: 10/7/2003
From: Berkshire, UK
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 7/5/2008 13:26:17   
I'm not sure that's quite right. Admittedly it doesn't show the image so you're not having to wait for it to appear but it still has to load the image and regardless of the display size you give it, the image size is still the image size.

_____________________________

If it ain't broke..... fix it until it is.
:)

:)
GAWDS
Now where did I put that Doctype?

(in reply to johnwboyd)
d a v e

 

Posts: 4170
Joined: 7/24/2002
From: England (but live in Finland now)
Status: offline

 
RE: Pre-load images using CSS (such as hover images) - 7/5/2008 13:44:01   
or you can position it (the swap image hover state) off the page with negative margins or such at its normal dimensions

_____________________________

David Prescott
Gekko web design

(in reply to johnwboyd)
Page:   [1]

All Forums >> Community >> OutFront Discoveries >> Pre-load images using CSS (such as hover images)
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts