Results 1 to 10 of 10

Thread: Script works Flawlessly in IE does *NOTHING* in firefox, I'm stumped

  1. #1
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Script works Flawlessly in IE does *NOTHING* in firefox, I'm stumped

    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:
    Code:
    	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.style.left=event.clientX+10+"px";
    		div.style.top=event.clientY+10+"px";
    		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.

    Code:
    <img src="images/question.png" alt="" onmouseover="detailOver('plans');" onmouseout="detailOut('plans');">
    and the div tag is:

    Code:
    	<div class="um" id="plans" style=" style="z-index: 100;">				
    		<h4 id="popuptitle">Plans</h4>
    		<p id="popupcontent">Information here!</p>
    	</div>
    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
    Code:
    <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.

    Michael
    Last edited by MikeDVB; 01-01-2008 at 01:59 AM. Reason: Added detail

  2. #2
    Join Date
    May 2007
    Location
    Canada
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.
    Last edited by pman; 01-01-2008 at 04:27 AM. Reason: adding suggestions

  3. #3
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    http://www.mddhosting.com/hosting.php

    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.

  4. #4
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  5. #5
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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,
    Michael

  6. #6
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could try any of these that work in FF, IE, etc.

    http://www.dynamicdrive.com/dynamicindex5/index.html

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  7. #7
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

    Michael

  8. #8
    Join Date
    Jun 2007
    Posts
    543
    Thanks
    3
    Thanked 78 Times in 78 Posts
    Blog Entries
    1

    Default

    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:
    Code:
    if (ie||ns6)
    thediv=document.all? document.all[id] : document.getElementById? document.getElementById(id) : ""
    [Jasme Library (Javascript Motion Effects)] My Site
    /\/\@§†ê® §©®¡þ† /\/\@|{ê®
    There are 10 kinds of people in the world, those that understand binary and those that don't.

  9. #9
    Join Date
    Dec 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Your call is wrong

    When you call your method you need to pass the event in any browser except IE.

    so:

    ...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.

  10. #10
    Join Date
    Dec 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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)

    Mike

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •