473,748 Members | 9,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

onmouseover hide/show description block: cross Browser problem

1 New Member
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;co lor:black;borde r-color:black;bor der-width:20; visibility:show ; left:25px; top:-100px; z-index:+1" onmouseover="ov erdiv=1;" onmouseout="ove rdiv=0; setTimeout('hid eLayer()',1000) ">
pop up description layer
</div>

<a href="#" onMouseOver="po pLayer(0)" onMouseOut="hid eLayer()"><font size=-1 face=arial><b>T HE JavaScript Source</b></font></a>

[/HTML]thanks.
Feb 14 '08 #1
1 3418
acoder
16,027 Recognized Expert Moderator MVP
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
17112
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 over the image. The images will flick through (at a rate of about 5 per second) then pause when the user onMouseOver's. Any help would be gratefully received. :o)
2
8748
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 always visible, and a blockquote which can be shown or hidden by clicking the link. Showing/hiding works, but the blockquote's margins behave a bit strange. I'll try to explain, though the best way to understand what happens is to go
19
6929
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 JavaScript in this code from a couple different sites but I'm not 100% sure what each line is doing...This is the ASP code that I'm using for the page....Take a look at the JavaScript code and please let me know what each line is doing....I have been...
3
2953
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 it's easy to get something wrong. If the browser does not support the required features, I want it to generate a completely static page with the "details" shown automatically.
0
1375
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 row of the table holds some stylesheet-controlled buttons, and the bottom row contains an IFRAME which loads a framed page. The problem is that whenever I mouseover a button in the top row of the table, one of the frames in the bottom row is...
1
5206
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 position:fixed over it (position:absolute in IE 5 and 6). The menue consists of two parts: an image and a header, both external links, in the upper div;
5
4626
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 that specific title, however, the mouseover is displaying all the descriptions for every title. Also, will you let me know if I have code in here that is not needed? I'm very new to php/js <script type="text/javascript" language="JavaScript">...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8831
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9548
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.