/    Sign up×
Community /Pin to ProfileBookmark

How do i get this to work?

im writing some javascript code that will show a “thumbnail” of a link’s webpage as the mouse is moved over said link, here is the code so far:

[CODE]anchors = document.getElementsByTagName(“a”);

thumbnailLink = “http://www.shrinktheweb.com/xino.php?embed=1&STWAccessKeyId=e756a2037c8a9ac&stwsize=lg&stwUrl=”;

for (i=0; i < anchors.length; i++){
linkhref = anchors[i].href;
anchors[i].addEventListener(‘mouseover’, function() { showThumbnail(linkhref) }, false);
anchors[i].addEventListener(‘mouseout’, hideThumbnail, false);
}

function showThumbnail(e){
alert(e);
}

function hideThumbnail(){
}[/CODE]

just to test i have made the showThumbnails function just output the argument to an alert box, the argument will be used to load the thumbnail once i develop the script

however, theres a problem, the link moveovers work, the alert appears, but with the same link, the last link that is on the page.

these lines are obviously not doing what i want:

[CODE]linkhref = anchors[i].href;
anchors[i].addEventListener(‘mouseover’, function() { showThumbnail(linkhref) }, false);[/CODE]

what should i do?

thanks

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@JpoelauthorSep 30.2009 — hmmm nobody got an idea?
×

Success!

Help @Jpoel 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.19,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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