Closed Thread Icon

Topic awaiting preservation: setTimeout Pages that link to <a href="https://ozoneasylum.com/backlink?for=8199" title="Pages that link to Topic awaiting preservation: setTimeout" rel="nofollow" >Topic awaiting preservation: setTimeout\

 
Author Thread
viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-01-2002 00:03

I'm trying to implent a timer in a tooltip, so it pops up after a period of time, but I'm not succeding. If I do this, just as a test:

code:
var avTimer;
function ShowTooltip(fArg) {
//avTimer = setTimeout("ShowTooltip2(" + fArg + ")",1000);
ShowTooltip2(fArg);
}
function HideTooltip(fArg) {
clearTimeout(avTimer);
HideTooltip2(fArg); }


it works fine, but no timer.
If I do this:

code:
var avTimer;
function ShowTooltip(fArg) {
avTimer = setTimeout("ShowTooltip2(" + fArg + ")",1000);
//ShowTooltip2(fArg);
}
function HideTooltip(fArg) {
clearTimeout(avTimer);
HideTooltip2(fArg); }


it doesn't work, it gives me an error.
What am I doing wrong?

[This message has been edited by viol (edited 06-01-2002).]

anomaly
Nervous Wreck (II) Inmate

From:
Insane since: May 2002

posted posted 06-01-2002 02:35

i think it's the expression you have in your setTimeout(). i've never used it with an expression. i could be wrong.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 06-01-2002 05:49

What's the error?

There shouldn't be anything wrong with using the expression like that.



.:[ The Tao of Steve ]:.
Be Desireless
Be Excellent
Be Gone
...................................

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 06-01-2002 08:31

It cracks me up when people say "there was an error" without giving the line number and/or what the error was. How are we supposed to figure it out? Sigh.

[edit: don't take this personally, you're one of many. Just give us the error and line number =) ]

[This message has been edited by Slime (edited 06-01-2002).]

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 06-01-2002 09:42

Viol, you didn't say what is contained in fArg variable. For example, if it is a string, your setTimeout stamenet should look like this (notice additional quotation marks):

avTimer = setTimeout("ShowTooltip2(\"" + fArg + "\")",1000);


viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-01-2002 20:05

Sorry about not informing the line number and error.
The error is "Object required".
The line number, well, I didn't know.
I use to never look at this piece of information because I don't have my scripts line numbered. I use Notepad to write them and Notepad has not a feature to number the lines.
After your comments, I decided to look for a better tool and, for my surprise, I found out that the error is occurring NOT in that code, but actually in the ShowTooltip2() function. For a reason that I don't know yet (I'm trying to figure it out), this function works fine when called directly but gives that error when called using the setTimeout function.
Here are the functions:

code:
function ShowTooltip2(fArg)
{
var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
if (tooltipOBJ != null) {
var tooltipLft = (document.body.offsetWidth?document.body.offsetWidth:document.body.style.pixelWidth) - (tooltipOBJ.offsetWidth?tooltipOBJ.offsetWidth :(tooltipOBJ.style.pixelWidth?tooltipOBJ.style.pixelWidth:300)) - 30;
if (navigator.appName != 'Netscape') {
var tooltipTop = (document.body.scrollTop>=0?document.body.scrollTop+10:event.clientY+10);
if ((event.clientX > tooltipLft) && (event.clientY < (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) + 10)) {
tooltipTop = (document.body.scrollTop?document.body.scrollTop:document.body.offsetTop) + event.clientY + 20;
}
tooltipOBJ.style.pixelLeft = tooltipLft; tooltipOBJ.style.pixelTop = tooltipTop;
}
else {
var tooltipTop = 10;
tooltipOBJ.style.left = tooltipLft; tooltipOBJ.style.top = tooltipTop;
}
tooltipOBJ.style.visibility = "visible";
}
}
function HideTooltip2(fArg)
{
var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
if (tooltipOBJ != null) {
tooltipOBJ.style.visibility = "hidden";
}
}


The error is happening at line 100, and line 100 means this line:

code:
if ((event.clientX > tooltipLft) && (event.clientY < (tooltipOBJ.scrollHeight?tooltipOBJ.scrollHeight:tooltipOBJ.style.pixelHeight) + 10)) {


Also, Arg has a number, not a string. At the html page, I have a div, that has the text to be tooltipped, like:

code:
<div class="CTooltip" ID="tt2">Bla bla bla ... ...</div>


and at the part I want the tip to popup, I have this:

code:
<tr onmouseover="ShowTooltip(2);" onmouseout="HideTooltip(2);"><td>Bla bla...</td></tr>


and ShowTooltip(2) is related to the ID="tt2", from the div tag.
At the .css file, I have:

code:
.CTooltip{
color:#FFEE00; font-size: 8pt;font-family: verdana,'MS Comic Sans',arial,sans-serif;
text-align:justify; position:absolute; top:0px; left:0px; z-index:50; width:280;
visibility:hidden; background-color: #555588; padding: 8px; border: 1px solid black;
FILTER: progid :DXImageTransform.Microsoft.Alpha(style=1,opacity=85,startX=0,finishX=0,startY=0,finishY=0);
}


This tooltip code was written not by me, it's from http://awstats.sourceforge.net/, the provider of my stats page. I just added the alpha filter and I'm trying to make it delay for a while before showing up.

[This message has been edited by viol (edited 06-01-2002).]

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-01-2002 20:20

By the way, the code above has a problem. The tooltip is supposed to stay always at the top right corner of the window, even if you scroll down the page. This feature works fine in IE but not in Netscape. In Netscape, the tooltip is always fixed, so if you scroll the page down, the tooltip is not seen.

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 06-02-2002 15:54

Did mrMaxs fix not work, thats what I was thinking, is fArg a string or a number ?

it will only go to the top regardless of the amount scrolled if you add a fsdfsd.top = topVar + scrollTopY or something, cant remember the exact code , but there is a simple enough fix, window.scrollY() or something ? no idea anywho, sorry Im no help , but I dont have a lot of time.

Or actually I wrote a script ages ago for a friend that used it .. here it is:
if(IE) document.body.scrollTop
if(NS &#0124; &#0124; NS6) window.pageYOffset


you'l figure it out.


viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-03-2002 08:21

I gave it up about the setTimeout.
But your tip about window.pageYOffset really solved the problem for Netscape.
Thanks.

beaner
Bipolar (III) Inmate

From: LA, CA, USA
Insane since: Apr 2002

posted posted 06-04-2002 17:49

I was having this problem too, try this if you still care.
setTimeout('ShowTooltip2("' + fArg + "')',1000);

And when it says object not defined doesn't necessarily mean that's where the error is.


viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 06-04-2002 23:35

Hi beaner,
I've tried avTimer = setTimeout('ShowTooltip2("' + fArg + "')',1000);
but it gives an error: "sequence constant not finalized" (translate)
So, I've tried avTimer = setTimeout('ShowTooltip2("' + fArg + '")',1000);
but still the same old error: object required.
Thanks anyway.

vto
Obsessive-Compulsive (I) Inmate

From: Godella, Valencia, Spain
Insane since: Feb 2002

posted posted 08-16-2002 19:06

Hi,

I would like to re-open these line. I had the same problem, at last I think the question is the use of a parameter that points to an object when I do these in a function using a setTimeout I had an error. If I put these object in a global var and don't use it in parameters it works fine.

Does someone test these?

« BackwardsOnwards »

Show Forum Drop Down Menu