Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Trouble with visited state using css image rollovers

Trouble with visited state using css image rollovers
Thread Tools
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 28, 2006, 08:31 AM
 
Hi,

Any help I can get on this would be greatly appreciated. I'm using a CSS image rollover on some links. All the states work except the visited state ... it just goes back to the inital state after clicking the link.

http://www.nomadicmind.com/Postings/index1d.html

Any ideas why?

Thanks.
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Jun 28, 2006, 06:33 PM
 
If I had to guess it's because <a href="javascript:toggleID(1);">Sample 1</a> isn't a page and so it can't really be visited.
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 28, 2006, 08:59 PM
 
That was my thought as well, so I placed a link to another page in the href. Nada. When I hit the back button in the browser the link still showed the intial state.
     
Mac Elite
Join Date: Oct 2000
Status: Offline
Reply With Quote
Jun 29, 2006, 08:57 AM
 
Originally Posted by headbirth
That was my thought as well, so I placed a link to another page in the href. Nada. When I hit the back button in the browser the link still showed the intial state.
It worked for me, if I just changed the URL to say http://www.google.com/ or some other page. Since you're using JavaScript, you might want to opt for a purely JavaScript approach. After the button has been clicked, have JS change the CSS and then set a cookie if you want it to stick.
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 29, 2006, 09:31 AM
 
Thanks for the info Synotic. I was going to fall back on JS as a last resort. Aside from creating separate pages can you think of another way to trick the browser? A CSS solution seems so much cleaner.
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Jun 29, 2006, 06:34 PM
 
put an actual address in the url (even if it's just an anchor on the same page), and place the javascript as an onclick event?
     
Mac Elite
Join Date: May 2002
Status: Offline
Reply With Quote
Jun 30, 2006, 01:17 PM
 
Hmmm... No go. I tried this:

<a href="#top" onclick="toggleID(1)">Sample 1</a>

Nothing in Safari and the rollover images are lost in Firefox.

Nice thought though.
     
Dedicated MacNNer
Join Date: Nov 2001
Location: Are Eye
Status: Offline
Reply With Quote
Jun 30, 2006, 02:13 PM
 
hmmm... what if you set the href to the image that gets swapped in and return false on the onclick handler so that the browser doesn't actually follow the link?

<a href="image.png" onclick="toggleID(1); return false;">

or some such thing. probably not. But that technique is at least accessible to non-javascript enabled users, if you're concerned about that.
     
   
Thread Tools
Forum Links
Forum 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 On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 10:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2