Forum Moderators: open
I noticed that the latest version of Trillian chat (trillian.cc) software provides definitions of words when you hover over them during chat from Wikipedia's dictionary (en.wiktionary.org/wiki/)
I was wondering if there is a javascript available that can do the same for web pages, so a page is scanned and when you hover over a word, it accesses Wikipedia and provides a definition?
Any suggestions would be welcome.
Thanks in advance
Words.txt:
banana
grapefruit
apple
grape
orange
Highlight.cgi (chmod 755 or rwxr-xr-x):
#!/usr/bin/perluse CGI;
print new CGI->header;
my $dopage=new CGI->param("page");
if(-e $dopage && -e "Words.txt")
{
open(PAGE, $dopage);
my @pg=<PAGE>;
close(PAGE);
open(WORDS, "Words.txt");
my @words=<WORDS>;
close(WORDS);
foreach(@words)
{
$d=$_;
$d=~s/\n//g;
foreach(@pg)
{
$_ =~ s/$d/<span style="text-decoration:underline">$d<\/span>/gi;
}
}
print @pg;
}
else
{
print "Error! Page does not exist!";
}
You can use this script by viewing (from a web browser) Highlight.cgi?page=hi.html where hi.html is a saved file, presumably containing some of the words.