Help with Image swap onmouseover event

Joined
Feb 4, 2010
Messages
28
Reaction score
0
Hi,

My onmousevent fails to switch the large photo with one of the smaller
images.

To be frank, I'm extremely new to Javascript programming and as such,
am trying to learn from other sites out there for sample code.

I can't see to determine the error.
>From my Frontpage editor, I receive the errors when I mouse over the

first image. (all images have the same problem.)

alt_0 is undefined
alt_1 is undefined (if i select the first image)

I've posted a sample page on my website to see if anyone can help

http://www.pctpoker.com/mens-poker-tshirts-detail-test.html

If anyone can point me in the right direction, that would be great.

Thanks,
Steve.
 
S

steve.peticca

(e-mail address removed) said the following on 3/10/2007 10:55 PM:
My onmousevent fails to switch the large photo with one of the smaller
images.

It is because you have a syntax error in your script block.
To be frank, I'm extremely new to Javascript programming and as such,
am trying to learn from other sites out there for sample code.

Most sites on the web, that attempt to teach Javascript, are junk. If
you got your eval code in that page from such a site, it proves my point.

Yours:
function preload(imgObj,imgSrc) {
if (document.images) {
eval(imgObj + ' = new Image()')
eval(imgObj + '.src = "' + imgSrc + '"')
}

}

Re-written:
function preload(imgObj,imgSrc){
if (document.images){
window[imgObj] = new Image();
window[imgObj].src = imgSrc;

}
}
I can't see to determine the error.

Open your page in Firefox, it points straight at the error in the Error
Console.
first image. (all images have the same problem.)

If FP produced that code, it makes me glad I don't use it.
alt_0 is undefined
alt_1 is undefined (if i select the first image)

Look in the script section that has those definitions. After the
clearColor function (which is a bad function of it's own) on the very
next line (you will have to scroll over to see it) there is an errant }
in the code.

Yours:
function clearColor(){
document.all.colorDisplayName.style.display= "none";}

Re-written:
function clearColor(){
document.getElementById('colorDisplayName').style.display = "none";

}

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/
Thanks for the suggestions, they did resolve my initial problem and
the swap image works for both IE and Firefox, albeit with some errors,
but its a start!

I still receive the following error:
Error: document.getElementById("colorDisplayName") has no properties
Source File: http://www.pctpoker.com/mens-poker-tshirts-detail-test.html
Line: 183

Based on what I could find in the maillist archives, it appears to be
a likely a syntax or html coding error.
Before I rip the entire pages apart to bare bones, can anyone see
something obvious I'm missing?

Thanks,Steve.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top