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 06-08-2012, 04:04 AM   PM User | #1
bennett
New to the CF scene

 
Join Date: Jun 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
bennett is an unknown quantity at this point
Rollover Swap on Image Seen Through Lightbox

I am only a few months into learning code. Here's my dilemma.

SITUATION:

I am using lightbox so when you click on an image (col1.jpg), it takes you into lightbox, opening another image (color1.jpg), and when you click next it takes you to the next image (color2.jpg). I want to make it so that when you rollover the image (color1.jpg) while in "lightbox mode" it will show another image.

Underneath col1.jpg is a word link (color), which takes you to the same series.

PROBLEM:

I think HTML rollovers won't work, because of the javascript already present in the file.

CODE:

<div class="image">
<a href="color1.jpg" rel="lightbox[colorsequence]"><img id="col1" class="all-four-rounded-corners" src="col1.jpg" alt="col1"/></a>
<a class="hidden" href="color2.jpg" rel="lightbox[colorsequence]">image #2</a>
<p><a href="color1.jpg" rel="lightbox[colorsequence2]">color</a></p>
<a class="hidden" href="color2.jpg" rel="lightbox[typesequence2]">image #2</a>
</div>

I KNOW THAT:

Mouseovers can work like this (and other ways, too):

<img src="image1.jpg" onmouseover="this.src='image2.jpg'" onmouseout="this.src='image1.jpg'">

BUT:

Should I use javascript instead?
What code do I want to use, and where do I put it?
Should I edit some of the javascript in my lightbox files?
bennett is offline   Reply With Quote
Old 06-08-2012, 01:28 PM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,615
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by bennett View Post
I think HTML rollovers won't work, because of the javascript already present in the file.
There is no such thing as “HTML rollovers”. This can only be achieved with CSS or JavaScript.
Quote:
Originally Posted by bennett View Post
Mouseovers can work like this (and other ways, too):

<img src="image1.jpg" onmouseover="this.src='image2.jpg'" onmouseout="this.src='image1.jpg'">

BUT:

Should I use javascript instead?
This is JavaScript. It’s written in the HTML code (i. e. “inline”) but it’s still JS.

Quote:
Originally Posted by bennett View Post
Should I edit some of the javascript in my lightbox files?
Yes, since you are invoking the functionality with the lightbox plugin you also need to modify it by modifying the lightbox script. However, the standard lightbox functionality wasn’t actually meant to be used that way. I think it would be better to create something from scratch (or look for a script that was exactly programmed for what you want) rather than trying to modify a pre-made plugin.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 06-08-2012, 02:07 PM   PM User | #3
bennett
New to the CF scene

 
Join Date: Jun 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
bennett is an unknown quantity at this point
Please Help With Javascript Modifications

Alright, thank you for your input; if I chose to attempt to modify my lightbox script, can anyone help me with what precise code to use and where to put it? I only really understand HTML and CSS; I've never actually written javascript.
bennett is offline   Reply With Quote
Reply

Bookmarks

Tags
image, javascript, lightbox, rollover, swap

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 02:11 AM.


Advertisement
Log in to turn off these ads.