PDA

View Full Version : Popup info box and ONMOUSEOVER not working with firefox



Trevzilla
06-06-2008, 06:19 PM
1) Script Title: Popup information box II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex5/popinfo2.htm

3) Describe problem: I am trying to implement this code into my website, with a few little modifications. First of all, the example code works fine on the dynamic drive website, but it does not work on my site. Secondly, what I have does work fine in Internet Explorer and Safari, but it does not work in Firefox. Just curious if I could get some help. . .

Firstly, I'll describe what I am trying to do. I am trying to have the popup information box pop up with dynamically created information in it. More or less, a person uploads a picture to my website, and I they input their name into a form. The name is then written to a mysql table. The Popup box then reads the name, and displays the message: "This picture was uploaded by: userX"

Now, what happens is this. Once again, it works perfectly in IE, but in Firefox the popup box appears only in the upper left corner, instead of following the mouse around. If you would like to see what I am talking about, here is the website address:

http://www.photomosaicproject.com/photographs.php

Here is the code that I believe is the problem:

echo '<a href="'.$row[0].'" target="_blank" ONMOUSEOVER="popup(\'This picture was uploaded by: '.$name[0].' '.$name[1].'\',\'lightyellow\');" ONMOUSEOUT="kill()"><img src="/uploads/'.$images[$i+1] .'" border=0 width=200 height=200></a>';

Other than that code, I've copied everything else verbatim from the example page.

Any ideas? Thanks!

Minos
06-07-2008, 02:47 AM
I'm heading to bed, so I'll check more tomorrow, but FF is throwing warnings..."Error parsing value 'left'", "Error parsing value 'top'". Something is screwy in that section of js, I think IE might be kind enough to ignore it.

Minos
06-07-2008, 10:57 AM
Alright, there's a couple things I changed, and then, of course, the all important fix.

Original:


function get_mouse(e){
var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left=x+Xoffset;
var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top=y+yyy;
}


First, yyy is only declared in another function, so it really "shouldn't" work here, so I replaced it with Yoffset, which is a global variable, same as Xoffset.

Second, and this is a quirk with Firefox 1.5+...well, I call it a quirk, though technically it's the proper way to code. Any value that you create dynamically, still needs to have a unit of measure! Ex., box.width = x becomes box.width = x+"px"
You can complain about how unfair this is, but frankly the unit of measure is VERY important. Ask NASA. So like I said, and is usually the case with Firefox-only errors, it's a coding problem that IE is kind enough to ignore. :)

Updated:

function get_mouse(e){
var x = (ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
skn.left= x + Xoffset +"px";
var y = (ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
skn.top= y + Yoffset + "px";
}

Trevzilla
06-08-2008, 08:13 PM
Worked perfectly! Thanks so much for that reply! I've been working on that for the past couple weeks, so it's nice to put it under the "completed" list! Thanks again!