View Full Version : Script works Flawlessly in IE does *NOTHING* in firefox, I'm stumped

01-01-2008, 01:50 AM
I hope I'm posting this in the correct location, this is the best place I could think to post it.

I have a script in a file called scripts.js

The script is:

function detailOver(d) {
var IE = document.all?true:false
var tempX = 0;
var tempY = 0;
var id = d;
var div = document.getElementById(id);

if (IE) { // grab the x-y pos.s if browser is IE
tempX = event.clientX + document.body.scrollLeft;
tempY = event.clientY + document.body.scrollTop;
} else { // grab the x-y pos.s if browser is NS
tempX = e.pageX;
tempY = e.pageY;
if (tempX < 0){tempX = 0}
if (tempY < 0){tempY = 0}

div.className = "um-hover";

function detailOut(d) {
var id = d;
var div = document.getElementById(id);
div.className = "um";

I have an image set up to show a div tag when moused over, and the divtag goes away on mouse out.

<img src="images/question.png" alt="" onmouseover="detailOver('plans');" onmouseout="detailOut('plans');">

and the div tag is:

<div class="um" id="plans" style=" style="z-index: 100;">
<h4 id="popuptitle">Plans</h4>
<p id="popupcontent">Information here!</p>

This is working flawlessly in Internet Explorer but it doesn't even appear to load in Firefox - even when I put a blatant error in the script I get no errors in FireFox (I do however get the errors in IE). I'm calling the code with
<script language="javascript" type="text/javascript" src="scripts.js"></script>

Either it's not loading, or for some reason the onmousenter onmouse out are not working in firefox.

Any help is appreciated. Thank you.


01-01-2008, 04:25 AM
Do you have a link that we can look at? Also, you probably don't need that "language" attribute on the script tag. I believe it's depricated already. The "type" attribute is all you need.

I would also recommend that you install the Firebug Add-on for Firefox. It'll save you a lot of time debugging javascript, DOM and css problems.

01-01-2008, 05:09 AM

The very first (top left) little question mark icon, when hovered over with mouse in IE pops up a DIV tag, in Firefox it does nothing.

The code is what was previously posted.

01-01-2008, 05:12 AM
The error it gives in firefox is that "e is not defined"; which is true as I do not see it in the script.

Hope this helps

01-01-2008, 05:55 AM
Ok... well it is working perfect in IE.

I need to do a few things but I've been trying all night to no avail.

1 - I need to know how to check between FireFox and Netscape, I believe (not certain) that the e.pageX and e.pageY will work in NS, just not in Firefox)

2 - I need cursor locating code for Firefox - I've been trying to find this ALL night to no avail. I have found code that works for IE, I need to test netscape and opera, but right now I am focusing on what I know doesn't work which is firefox.

If anybody can offer any kind of assistance I'd greatly apprecaite it as I've been searching all night and can't seem to figure this out.

Thank you for your help,

01-01-2008, 06:01 AM
You could try any of these that work in FF, IE, etc.


Hope this helps.

01-01-2008, 03:20 PM
I wasn't able to get those scripts customized like I needed (to move a changing div tag, instead of one specific tag and changing it's contents)

But with firebug I was able to see what I was doing wrong.

Thank you so much guys.

The reason for having it move different div tags is because I include the popup divs in a separate file and use PHP to include them.

Thank you.


01-01-2008, 04:43 PM
Did you fix it though? I went over your site in firebug and it said
thediv has no properties
I believe the line in question is this:

if (ie||ns6)
thediv=document.all? document.all[id] : document.getElementById? document.getElementById(id) : ""

01-01-2008, 08:23 PM
When you call your method you need to pass the event in any browser except IE.


...onmouseover="detailOver( event, 'plans' );"

ditto for your mouseout event...

then in your function, you need to define it like:

function detailOver( e, d){
//e is the event you are passing in... in IE, it will be null, but that is why you
//are grabing it from the global namespace.

if you keep everything else the same it will work like a charm.

01-01-2008, 09:02 PM
Yes I have it working in IE and Firefox now, I haven't tested netscape or opera yet.

You probably checked the script when I was trying to change it's function a little (I've been tweaking it all day) lol

Thank you for your help!

Couldn't have done it without you guys (believe me, I tried)