hi there i have a link in my pge and on mouseover i want to show the tooltip by getting the coordinates x and y from the screen where the onmouseover event occoured can any one teell me the way to get the right coordinates in
IE and FF my code is not working properly or say it is not a generic code that i could reuse it has the positioning problem so in all my sites where i have to use the tooltip i have to position is manually on that page ....although it gives me correct out put if i make link on a blank page and try to hover it i get the exact position of the tooltip right under my mouse but when i try to embed into my page its all a fussssss and i have to add up some pixels manually to do that and yes i have to swap the x and y coordinates to position the tooltip menas in normal blank page i use -
prevWin.style.top= parseInt(yPos)+'px';
-
prevWin.style.left= parseInt(xPos)+20+'px';
-
but when i copy paste the same code into my page it starts to display the tooltip on the top and i have to omit the top and assign the xPos to left only -
prevWin.style.left = parseInt(xPos)-300+'px';
-
how stupid can any one help me i am tired of looing on to available tooltip i have to make my own ,here is my code
file:tooltip.js -
var xhr = false;
-
var xhr = false;
-
var xPos,yPos;
-
var xhr;
-
function showPreview(evt,id,diff){
-
getPreview(evt,id,diff);
-
return false;
-
}
-
function hidePreview(){
-
document.getElementById("previewWin"). style.visibility = "hidden";
-
}
-
function hidePreview_m(){
-
document.getElementById("previewWin_m"). style.visibility = "hidden";
-
}
-
function getPreview(evt,id,diff){
-
if (evt){
-
var url = evt.target;
-
}
-
else{
-
evt = window.event;
-
var url = evt.srcElement;
-
}
-
alert(evt.srcElement);
-
//my added
-
if(diff=="mold"){
-
url = "ajax/mold_tip.php?item_name="+id;
-
}else{
-
url = "ajax/tooltip_temp.php?item_name="+id;
-
}
-
//my added
-
xPos = evt.clientX;
-
yPos = evt.clientY;
-
if (window.XMLHttpRequest){
-
xhr = new XMLHttpRequest();
-
}
-
else {
-
if(window.ActiveXObject){
-
try {
-
xhr = new ActiveXObject ("Microsoft.XMLHTTP");
-
}
-
catch(e){ }
-
}
-
}
-
if(xhr){
-
if(diff!="mold"){
-
xhr.onreadystatechange = showContents;
-
xhr.open("GET", url, true);
-
xhr.send(null);
-
}else{
-
xhr.onreadystatechange = showmolds;
-
xhr.open("GET", url, true);
-
xhr.send(null);
-
}
-
}
-
else {
-
alert("Sorry, but I couldn't create an XMLHttpRequest");
-
}
-
}
-
function showmolds(){
-
var prevWin = document.getElementById ("previewWin_m");
-
hidePreview();
-
if(xhr.readyState==4){
-
var innerHtml;
-
var a=(xhr.status==200) ? xhr.responseText : "There was a problem with the request " + xhr.status;
-
innerHtml=a;
-
prevWin.innerHTML=innerHtml;
-
prevWin.style.top='0px';
-
prevWin.style.top= parseInt(yPos)+170+'px';
-
prevWin.style.left= parseInt(xPos)+20+'px';
-
prevWin.style.visibility = "visible";
-
}
-
}
-
function showContents(){
-
var prevWin = document.getElementById ("previewWin");
-
hidePreview_m();
-
if(xhr.readyState==4){
-
var innerHtml;
-
//innerHtml='<div class="floater tip_close" onclick="hidePreview()"></div>';
-
var a=(xhr.status==200) ? xhr.responseText : "There was a problem with the request " + xhr.status;
-
innerHtml=a;
-
prevWin.innerHTML=innerHtml;
-
prevWin.style.top= parseInt(yPos)+170+'px';
-
prevWin.style.left= parseInt(xPos)+20+'px';
-
//prevWin.style.top = parseInt(xPos)+2+'px';
-
//prevWin.style.left = parseInt(xPos)-300+'px';
-
prevWin.style.visibility = "visible";
-
//prevWin.onmouseout = hidePreview;
-
}
-
}
-
file:tooltip.css -
#previewWin {
-
width:440px;
-
height:auto;
-
position: absolute;
-
visibility: hidden;
-
overflow: hidden;
-
cursor:pointer;
-
}
-
#previewWin_m{
-
width:440px;
-
height:auto;
-
position: absolute;
-
visibility: hidden;
-
overflow: hidden;
-
cursor:pointer;
-
}
-
file:index.php -
<table cellspacing="0" cellpadding="0" align="center" border="0" width="981">
-
<tr>
-
<td align="left" valign="middle" colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="0" class="detail_bg">
-
<tr>
-
<td><span class="text_white_18_bold"> DETAILS:</span><span class="text_white_11"><strong><a href="#." style="cursor:pointer; text-decoration:none;" class="text_white_11" onmouseover="showPreview(event,'<?=$design_info['design_mould'];?>','mold')"><?=$design_info['design_mould']?></a> with
-
<?
-
$link_1="";
-
$link_2="";
-
$link_3="";
-
$link_4="";
-
$first=explode(",",$design_info['design_special_adons']);
-
$f_a_1=$first[0];
-
$f_a_2=$first[1];
-
$f_a_3=$first[2];
-
$f_a_4=$first[3];
-
if($f_a_1){
-
$link_1="<a href=\"#.\" class=\"text_white_11\" onmouseover=\"showPreview(event,'$f_a_1','')\">$f_a_1</a>";
-
}
-
if($f_a_2){
-
$link_2="<a href=\"#.\" class=\"text_white_11\" onmouseover=\"showPreview(event,'$f_a_2','')\">$f_a_2</a>";
-
}
-
if($f_a_3){
-
$link_3="<a href=\"#.\" class=\"text_white_11\" onmouseover=\"showPreview(event,'$f_a_3','')\">$f_a_3</a>";
-
}
-
if($f_a_4){
-
$link_4="<a href=\"#.\" class=\"text_white_11\" onmouseover=\"showPreview(event,'$f_a_4','')\">$f_a_4</a>";
-
}
-
?>
-
<?=$link_1; if($link_2<>""){ echo ", ".$link_2;}?> </strong></span></td>
-
</tr>
-
</table>
-
<div id="previewWin"></div>
-
<div id="previewWin_m"></div>
-
regards omer
ok, a simple sample: - var elem = document.getElementById(_element_id_);
-
elem.setAttribute("title", _text_from_ajax_);
note: entities inside the text are not rendered, but since javascript uses unicode natively, you can convert them before returning the request to the javascript.
5 2505
you could use the title attribute.... works even with javascript turned off
regards
you could use the title attribute.... works even with javascript turned off
regards
ineed to use ajax cause the content loaded is dyanamic could be changed after wards i have to do it this way and how can i postion the div by using title only ????????
regards ,
omer
as I understand it, you want a tooltip over a special element (using its id) and there seems to be only a text message...
I still would use title attribute because
- you can dynamically create/remove it (createAttribute())
- it shows whenever (and wherever) the mouse hovers over that element (no need of an event at all)
- you can change the content to your liking
regards
as I understand it, you want a tooltip over a special element (using its id) and there seems to be only a text message...
I still would use title attribute because
- you can dynamically create/remove it (createAttribute())
- it shows whenever (and wherever) the mouse hovers over that element (no need of an event at all)
- you can change the content to your liking
regards
can you give an example or alink to any page that can show how tomake that simple tooltip working
regards,
omer
ok, a simple sample: - var elem = document.getElementById(_element_id_);
-
elem.setAttribute("title", _text_from_ajax_);
note: entities inside the text are not rendered, but since javascript uses unicode natively, you can convert them before returning the request to the javascript.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Yves Royer |
last post by:
Hi,
I'm currently writing an application (in VS 2005 bèta 2) and made some own
user controls. In each user control I added a ToolTip object so i can set
some tooltips on checkboxes etc.
What...
|
by: Yves Royer |
last post by:
Hi,
My first post didn't show up so here's a second try.
I'm currently writing an application (in VS 2005 bèta 2) and made some own
user controls. In each user control I added a ToolTip object...
|
by: ltt19 |
last post by:
HI everyone,
So, I have many buttons, and all of them must show a tooltip with the same
string, except one word, that I must read this owrd from a variable.
Although, the "ToolTip on x" property...
|
by: EricL |
last post by:
Hello,
I have written a Custom Control which inherits from ToolTip and it is an
OwnerDraw tooltip.
In the Popup event I calculate the size of the tooltip I need to display
(rather large...
|
by: =?Utf-8?B?cGV0ZTE5Njk=?= |
last post by:
I use Visual Studio 2005 and created a very simple Form with one button. I
added a Tooltip for that button. It shows fine the first time I hover over
that button. But if I let it disappear by the...
|
by: john |
last post by:
I have the following textbox setup with Text & ToolTip Bindings as follows;
I'm using Visual Studio 2008 VB:
<asp:TextBox ID="txtDay1" runat="server"
Text='<%# Eval("Day1") %>'...
|
by: omerbutt |
last post by:
hi there i have downloaded a prototype tooltip from
http://www.nickstakenburg.com/projects/prototip/
the logic it uses is to call the script after creating the <div> for example i am using the...
|
by: omerbutt |
last post by:
hi there i have tried to make my own AJAX tooltip it works all right and every things fine and the tooltip display right under the element i want to display untill unless i switch my resolution, it...
|
by: Charles Law |
last post by:
I have to take this personally now. Tooltips have been flakey since the dawn
of .NET, but to still have to put up with a disappearing tooltip in VS 2008
is getting beyond a joke. Tooltips have...
|
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...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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,...
|
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...
|
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,...
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |