473,657 Members | 2,586 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Popup/tooltip doesn't work with Mozilla

258 Contributor
Hi everyone
Actually I'm a php programer and don't no so much about java. After searching on google I found the java code you see below to open a popup when user moves the mouse pointer over a link. The code works fine with IE but not with Mozilla. Does anyone know why?

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.  
  3. function initalt()
  4. {
  5. altback="gray" 
  6. altborder="white"
  7. altfont="arial"  // Alt-Message Font
  8. altfontcolor="white"// Alt-Message Font color
  9. altfontsize="2" // Alt-Message Font Size
  10. altoffx=5 // Alt-Message horizontal offset from mouse-position
  11. altoffy=15 // Alt-Message vertical offset from mouse-position
  12. altwidth=150 // Alt-Message width, will be expanded by your message
  13. altheight=0 // Alt-Message height, will be expanded by your message
  14. // end of Variables
  15.  
  16.                 document.onmousedown = sniff
  17.                 document.onmousemove = sniff
  18.                 document.onmouseup = sniff
  19.   if (document.layers) 
  20.   {  //NS
  21.   document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP)
  22.   document.layers['altmessage'] = new Layer(altwidth)
  23.   document.layers['altmessage'].left = 0
  24.   document.layers['altmessage'].top = 0
  25.   document.layers['altmessage'].height = altheight
  26.   document.layers['altmessage'].bgColor = altback
  27.   document.layers['altmessage'].visibility = "hidden"
  28.   document.layers['altmessage'].borderStyle = "solid"
  29.   document.layers['altmessage'].borderColor = altborder
  30.   document.layers['altmessage'].borderWidth = 1
  31.   }
  32.   else if (document.all)
  33.   { //IE
  34.   document.body.insertAdjacentHTML("BeforeEnd",'<DIV ID="altmessage" STYLE="z-index:200;position:absolute;width:'+altwidth+';height:'+altheight+';left:0;top:0;visibility:hidden;background:'+altback+';border-style:solid;border-width:1;border-color:'+altborder+'"></DIV>')
  35.   }
  36.   }
  37.  
  38.         function sniff(e) 
  39.         {
  40.         // GETS Mouseposition
  41.         if (document.layers)
  42.         {
  43.         var mousex=e.pageX; var mousey=e.pageY;document.layers['altmessage'].left = mousex+altoffx;document.layers['altmessage'].top = mousey+altoffy
  44.         }
  45.         else if (document.all)
  46.         {
  47.         var mousex=event.x; var mousey=event.y+document.body.scrollTop;altmessage.style.top=mousey+altoffy;altmessage.style.left=mousex+altoffx
  48.         }
  49.         }
  50.  
  51.        function doalt(message)
  52.        {
  53.        //The main routine
  54.        content='<font face="'+altfont+'" size="'+altfontsize+'" color="'+altfontcolor+'">'+message+'</FONT>'                
  55.        if (document.layers) 
  56.        {
  57.        with (document.layers['altmessage'].document)
  58.        {
  59.          open()
  60.        write(content)
  61.        close()
  62.        }
  63.        document.layers['altmessage'].visibility = "show"
  64.        }
  65.        else if (document.all) 
  66.        { 
  67.         document.all['altmessage'].innerHTML = content
  68.         document.all['altmessage'].style.visibility = "visible"
  69.        }
  70.        }
  71.        function realt()
  72.        {
  73.        if (document.layers)document.layers['altmessage'].visibility = "hidden";
  74.        else if (document.all) document.all['altmessage'].style.visibility = "hidden";
  75.        }
  76. </script>
  77.  
  78.  
I put this code between HEAD tags and then make my links like this

Expand|Select|Wrap|Line Numbers
  1. <body onload="initalt();">
  2. <a href="index.php" onmouseover="doalt('your message');" onmouseout="realt();">Some text</a>
  3. </body>
  4.  
Oct 26 '07 #1
7 4251
Ferris
101 New Member
hi

It seems very difficult to edit your code to make it work with Mozilla. Your code is totally designed for IE and NetScape 4.x. I suggest you reGoogle the code you want.

hope it helps.
Oct 28 '07 #2
bnashenas1984
258 Contributor
Hi
Thanks for the reply
Actually I'v been searching for this script and this is the only one I found. Other ones were too much for my website (like big popup windows with backgrounds and even sound).. I just need a little popup to show a text with a border and thats it. It doesn't seem so complicated.

Does anyone have such a script?
Thanks
Oct 28 '07 #3
bnashenas1984
258 Contributor
Hi everyone
The script you see below moves a text "Tooltip" to mouse pointer position it works fine in IE but it doesn't work in mozilla
Does anyone know why???

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <script language="JavaScript1.2">
  5. <!--
  6. function showtooltip() {
  7. var IE = document.all?true:false
  8.  
  9. if (!IE) document.captureEvents(Event.MOUSEMOVE)
  10.  
  11. var tempX = 0
  12. var tempY = 0
  13.  
  14.   if (IE) { // grab the x-y pos.s if browser is IE
  15.     tempX = event.clientX + document.body.scrollLeft
  16.     tempY = event.clientY + document.body.scrollTop
  17.   } else {  // grab the x-y pos.s if browser is NS
  18.     tempX = e.pageX
  19.     tempY = e.pageY
  20.   }  
  21.  
  22.   if (tempX < 0){tempX = 0}
  23.   if (tempY < 0){tempY = 0}  
  24.   document.getElementById('tooltip').style.left=tempX+10
  25.   document.getElementById('tooltip').style.top=tempY-10
  26.   document.getElementById('tooltip').style.display="block";
  27.   return true
  28. }
  29.  
  30. //-->
  31. </script>
  32.  
  33. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  34. <title>Untitled Document</title>
  35. </head>
  36.  
  37. <body>
  38.  
  39. <div id="tooltip" style="position:absolute; left:200px">Tooltip</div>
  40.  
  41. <a href="" onmousemove="showtooltip()" onMouseout="document.getElementById('tooltip').style.display='none';">Some text</a>
  42. </body>
  43. </html>
  44.  
Oct 29 '07 #4
Logician
210 New Member
Hi everyone
The script you see below moves a text "Tooltip" to mouse pointer position it works fine in IE but it doesn't work in mozilla
Does anyone know why???

Expand|Select|Wrap|Line Numbers
  1. document.getElementById('tooltip').style.left=tempX+10
  2.   document.getElementById('tooltip').style.top=tempY-10
Try amending those lines thus:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById('tooltip').style.left=tempX+10+'px';
  2. document.getElementById('tooltip').style.top=tempY-10+'px';
Oct 29 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
You could Google for "javascript tooltip".

If you're going to do it yourself, get the mouse position and display the div at that position on the screen.
Oct 29 '07 #6
acoder
16,027 Recognized Expert Moderator MVP
Threads on same topic merged.
Oct 29 '07 #7
Logician
210 New Member
Hi
Thanks for the reply
Actually I'v been searching for this script and this is the only one I found. Other ones were too much for my website (like big popup windows with backgrounds and even sound).. I just need a little popup to show a text with a border and thats it. It doesn't seem so complicated.

Does anyone have such a script?
Try UltimaTips. You can use it to replace the standard title text or specify your own separate text using your own stylesheet. It also displays hidden elements adjacent to the cursor.
Oct 29 '07 #8

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

Similar topics

10
2743
by: Oliver | last post by:
Hello, i'm having trouble with a css type popup. It's not doing what i want in Mozilla 1.6 and in IE6.0 it's not working at all. The html code looks like this: <div class="themenkueche" id="tk"> <h1>Themenk&uuml;chen</h1> <p>
8
41576
by: Orloff | last post by:
Hi, on most (all?) browsers, when you put the pointer on a <a href="..." title="popup text">this is a link</a> without clicking on the link, there is a popup caption with the "popup text". I would like to achieve the same with some text that is not a link. I realized that I could simply make it <a title="popup text">this is just some text</a>
5
2854
by: Hemanth | last post by:
Hello there, I'm running a script that opens a popup window (which is basically a form with checkboxes and a submit button). When I click the submit button I want to run a PHP script and target the result to main page (I mean, update the parent page). My popup form looks like this: <form name="form1" action="run.php" method="get" target="???">
4
2398
by: Rusty | last post by:
Hi, I've seen something on a web site that I want to do for our Intranet web site. I'm not advocating pop-ups but for our company app, this would be perfect. Please go to this page and hold your mouse over one of the rings. http://www.bluenile.com/product_catalog.asp?catid=8&oid1=364&track=hero& elem=img The middle ring on the top brings up this page, but in a pop-up form.
5
1257
by: ODAN | last post by:
I have an application that was developed in ASP.NET/C#. On one of the pages, we are using tooltip to display the description of the textboxes. Wehn you move your mouse over a textbox the tooltip appears with a full description of the textbox on which you have your mouse. By default the tooltip display for 10 seconds and then disappear (according to Microsoft). Is there a way to make the tooltip display indefinetly. I have I searched the...
4
6810
by: jobs | last post by:
the javascript: function ShowTooltip(L1in) { document.getElementById("L1").innerText=L1in; y = event.clientY + document.documentElement.scrollTop; var Popup= document.getElementById("Popup") Popup.style.display="block"; Popup.style.position="absolute"; Popup.style.left = 220;
3
7363
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for main window to call function in the popup window, right? The following is a sample code (close popup window causes to show alert window) which doesn't seems to work. Can anyone see the problem? // main
1
3998
by: tshad | last post by:
I am trying to use a popup control extenter which works fine the following way where we have an object and a popcontrolextender objec that points to this object. <asp:ImageButton ID="ibPractitioners" runat="server" ImageUrl="~/images/icons/user_16.gif" ToolTip="Display Practitioners" Visible='<%# Convert.ToBoolean(Eval("PractitionersVisible")) %>' CommandName="practitioners" CssClass="action" />
7
2547
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello, I'm using the ToolTip control, but I want it to behave a bit different. I want the toolTip to popup not only once when the control is enter and the mouse is stationary. I want the toolTip to popup every time the mouse is stationary over the control without the mouse leaving and entering the control again. How can I do that? Even by overriding the ToolTip class?
0
8305
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
8823
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
8730
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...
0
7321
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...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4301
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1607
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.