473,387 Members | 1,517 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

onmouseover hide/show description block: cross Browser problem

1
This javascript shows and hides description (like alt in image tag). It works in IE but not in Mozilla, what is wrong please help:

Expand|Select|Wrap|Line Numbers
  1. <SCRIPT LANGUAGE="JavaScript">
  2.  
  3. // ############## SIMPLE BROWSER SNIFFER
  4. if (document.layers) {navigator.family = "nn4"}
  5. if (document.all) {navigator.family = "ie4"}
  6. if (window.navigator.userAgent.toLowerCase().match("gecko")) {navigator.family = "gecko"}
  7.  
  8. // ######### popup text
  9. descarray = new Array(
  10. "This site has some of the greatest scripts around!"
  11. );
  12.  
  13. overdiv="0";
  14. // ######### CREATES POP UP BOXES
  15. function popLayer(a){
  16. if(!descarray[a]){descarray[a]="<font color=red>This popup (#"+a+") isn't setup correctly - needs description</font>";}
  17. if (navigator.family == "gecko") {pad="0"; bord="1 bordercolor=black";}
  18. else {pad="1"; bord="0";}
  19. desc = "<table cellspacing=0 cellpadding="+pad+" border="+bord+" bgcolor=000000><tr><td>\n"
  20. +"<table cellspacing=0 cellpadding=3 border=0 width=100%><tr><td bgcolor=ffffdd><center><font size=-1>\n"
  21. +descarray[a]
  22. +"\n</td></tr></table>\n"
  23. +"</td></tr></table>";
  24. if(navigator.family =="nn4") {
  25. document.object1.document.write(desc);
  26. document.object1.document.close();
  27. document.object1.left=x+15;
  28. document.object1.top=y-5;
  29. }
  30. else if(navigator.family =="ie4"){
  31. object1.innerHTML=desc;
  32. object1.style.pixelLeft=x+15;
  33. object1.style.pixelTop=y-5;
  34. }
  35. else if(navigator.family =="gecko"){
  36. document.getElementById("object1").innerHTML=desc;
  37. document.getElementById("object1").style.left=x+15;
  38. document.getElementById("object1").style.top=y-5;
  39. }
  40. }
  41. function hideLayer(){
  42. if (overdiv == "0") {
  43. if(navigator.family =="nn4") {eval(document.object1.top="-500");}
  44. else if(navigator.family =="ie4"){object1.innerHTML="";}
  45. else if(navigator.family =="gecko") {document.getElementById("object1").style.top="-500";}
  46. }
  47. }
  48.  
  49. // ######## TRACKS MOUSE POSITION FOR POPUP PLACEMENT
  50. var isNav = (navigator.appName.indexOf("Netscape") !=-1);
  51. function handlerMM(e){
  52. x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
  53. y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
  54. }
  55. if (isNav){document.captureEvents(Event.MOUSEMOVE);}
  56. document.onmousemove = handlerMM;
  57. // End -->
  58. </script>
==========================================
and body:

[HTML]<div id="object1" style="position:absolute; background-color:FFFFDD;color:black;border-color:black;border-width:20; visibility:show; left:25px; top:-100px; z-index:+1" onmouseover="overdiv=1;" onmouseout="overdiv=0; setTimeout('hideLayer()',1000)">
pop up description layer
</div>

<a href="#" onMouseOver="popLayer(0)" onMouseOut="hideLayer()"><font size=-1 face=arial><b>THE JavaScript Source</b></font></a>

[/HTML]thanks.
Feb 14 '08 #1
1 3391
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

The code uses browser detection - it would be better using object/feature detection, but anyway...

Firefox/Mozilla requires you to give units, e.g. "px" for the position properties (top, left, etc.)
Feb 14 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Tim | last post by:
Hope someone in the big wide world can help... What I want to do is have an image slideshow which automatically scrolls through a series of images very fast, then pauses when you move your mouse...
2
by: steven | last post by:
Hi, sorry for the crosspost, but I'm not sure if my problem is with the HTML or the CSS :-( URL: http://www.nenya.be/temp/list.htm I have a list with in each list item a text + link which are...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
3
by: alex | last post by:
I'd like to have a show/hide widget on my web site, kind of like "show details" / "hide details" in Google Groups. Is there a tutorial explaining how to make them? Google's is a bit complex and...
0
by: jceddy | last post by:
Hi...I hope I am posting this in an appropriate place...if not, could some direct me to someplace better? Anyway, the problem I have is that I have a page with a table with two rows. The top...
1
by: Ciuin | last post by:
Again I need your help. This is the test page I am working on: http://www.manfredkooistra.de/zeugs/test/test.php Description: The page shows a centered image and a navigation menue...
5
by: jkershner | last post by:
I have a js script inside php code that is connected to mysql, the php code is listing the results from the query then, the onmouseover function is supposed to show the description of the title for...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.