Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-05-2013, 05:16 AM   PM User | #1
jorwesflow
New to the CF scene

 
Join Date: Mar 2013
Location: CT
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
jorwesflow is an unknown quantity at this point
Image hover/rollover/mouseover: back button breaks mouseout

Please see the three image links in the middle of the page: http://spncolors.com/shop/. If you hover over and then click, you're taken to the appropriate page. But now click the back button and the image stays frozen in its "mouseover" state, rather than reverting to the "mouseout" state. Firefox and Safari have both shown this problem. Chrome seems to be okay however.
I'm a total amateur here, so any help is appreciated. Here is my code:

Code:
jQuery(function($) {
$(document).ready(function() {

		// Preload all rollovers
		$("#hoverlink img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.jpg$/ig,"-over.jpg");
			$("<img>").attr("src", rollON);
		});

		// Navigation rollovers
		$("#hoverlink a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/-over/);

			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.jpg$/ig,"-over.jpg"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);
			}

		});
		$("#hoverlink a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);
		});

	});
});
jorwesflow is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 05:55 AM.


Advertisement
Log in to turn off these ads.