/    Sign up×
Community /Pin to ProfileBookmark

This is a small script to display a floating box that follows the mouse when the mouse is over a link, but it only brings up the box and doesnt follow the mouse.. If ya get me.

[code]
var tid = 0, x = 0, y = 0;

document.onmousemove=track;

function track(e)
{
x = (document.all) ? event.x : e.pageX;
y = (document.all) ? event.y : e.pageY;
}

function show(id)
{
obj = document.getElementById(“popup” +id);
obj.style.left = x – 20; / /Error: obj has no properties . It’s weird, it only errors on this line of code
but manages to retrieve all the rest of the data from the object,
like the one below.
obj.style.top = y – 45;
obj.style.display = “block”;
tid = window.setTimeout(“show()”,1);
}

function hide(id)
{
obj = document.getElementById(“popup” +id);
window.clearTimeout(tid);
obj.style.display = “none”;
}
[/code]

The code should work, as when the getelementbyid line is outside of the function it works perfectly ? Anybody help out a noob?? Pleeease.

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Wisest_GuyFeb 02.2006 — Which object has no properties?
Copy linkTweet thisAlerts:
@CrazyMerlinFeb 02.2006 — try eval("popup" + id)
Copy linkTweet thisAlerts:
@lumberjake2authorFeb 02.2006 — @ Wisest guy

obj = document.getElementById("popup" +id);

this one i think. But it only says it has no properties for this one line of code.

obj.style.left = x - 20;

@ CrazyMerlin.

I dont really know how to use the eval function or know what it does. ?

Thanks for the replies guys.
Copy linkTweet thisAlerts:
@Wisest_GuyFeb 02.2006 — Try this:
[CODE]
obj.style.left =
x - 20;
[/CODE]
Copy linkTweet thisAlerts:
@lumberjake2authorFeb 02.2006 — Nope the same outcome ?
Copy linkTweet thisAlerts:
@Wisest_GuyFeb 02.2006 — But which line is the error on?
Copy linkTweet thisAlerts:
@lumberjake2authorFeb 02.2006 — Line 14.

obj.style.left = x - 20;
Copy linkTweet thisAlerts:
@lumberjake2authorFeb 02.2006 — Nevermind i fixed it. The timeout wasn't passing the variable id on on recursion, i just changed tid = window.setTimeout("show()",1); to tid = window.setTimeout("show("+id+")",1);

Thanks anyway guys
×

Success!

Help @lumberjake2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...