Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #15004 > unrolled thread

Grabbing words/text under mouse?

Started byMichael Joel <null@void.void>
First post2012-07-10 15:01 -0400
Last post2012-07-11 21:15 +0100
Articles 10 — 7 participants

Back to article view | Back to comp.lang.javascript


Contents

  Grabbing words/text under mouse? Michael Joel <null@void.void> - 2012-07-10 15:01 -0400
    Re: Grabbing words/text under mouse? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-10 19:39 +0000
      Re: Grabbing words/text under mouse? Michael Joel <null@void.void> - 2012-07-10 19:46 -0400
        Re: Grabbing words/text under mouse? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-11 08:39 +0000
        Re: Grabbing words/text under mouse? Scott Sauyet <scott.sauyet@gmail.com> - 2012-07-12 19:40 -0700
          Re: Grabbing words/text under mouse? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-07-13 07:06 +0000
    Re: Grabbing words/text under mouse? Eli the Bearded <*@eli.users.panix.com> - 2012-07-10 19:42 +0000
      Re: Grabbing words/text under mouse? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-07-10 22:32 +0200
    Re: Grabbing words/text under mouse? Martin Honnen <mahotrash@yahoo.de> - 2012-07-11 13:08 +0200
    Re: Grabbing words/text under mouse? Dr J R Stockton <reply1228@merlyn.demon.co.uk.not.invalid> - 2012-07-11 21:15 +0100

#15004 — Grabbing words/text under mouse?

FromMichael Joel <null@void.void>
Date2012-07-10 15:01 -0400
SubjectGrabbing words/text under mouse?
Message-ID<Q5ydnay5Dr1l5mHSnZ2dnUVZ_j-dnZ2d@earthlink.com>
I want to be able to get word definitions to display when a user double 
clicks a word being displayed. The text is being loaded out of a mysql 
database and I am working with it in PHP.

I figured javascript is the only way I know to directly interact with 
the user and browser.

I tried enclosing each word with a div or href but not only does it take 
a long time to process but it really doesn't work with other formatting 
the text undergoes.

So is there a way to get the word/text that was under the mouse when it 
was double clicked?

Thanks
Mike

[toc] | [next] | [standalone]


#15005

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-07-10 19:39 +0000
Message-ID<XnsA08CDC5415D5Aeejj99@194.109.133.133>
In reply to#15004
Michael Joel wrote on 10 jul 2012 in comp.lang.javascript:

> I want to be able to get word definitions to display when a user double 
> clicks a word being displayed. The text is being loaded out of a mysql 
> database and I am working with it in PHP.
> 
> I figured javascript is the only way I know to directly interact with 
> the user and browser.
> 
> I tried enclosing each word with a div or href but not only does it take 
> a long time to process but it really doesn't work with other formatting 
> the text undergoes.
> 
> So is there a way to get the word/text that was under the mouse when it 
> was double clicked?

Yes.

The simplest way is not clientside javascript, though, 
just HTML and serverside scripting, possibly in javascript.

Try it, and we could help if you get stuck,
if you use serverside javascript that is, 
otherwise ask in the appropriate NG.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#15012

FromMichael Joel <null@void.void>
Date2012-07-10 19:46 -0400
Message-ID<qe6dnVrr4sUkI2HSnZ2dnUVZ_j6dnZ2d@earthlink.com>
In reply to#15005
Evertjan. wrote:
> Michael Joel wrote on 10 jul 2012 in comp.lang.javascript:
> 
> 
>>I want to be able to get word definitions to display when a user double 
>>clicks a word being displayed. The text is being loaded out of a mysql 
>>database and I am working with it in PHP.
>>
>>I figured javascript is the only way I know to directly interact with 
>>the user and browser.
>>
>>I tried enclosing each word with a div or href but not only does it take 
>>a long time to process but it really doesn't work with other formatting 
>>the text undergoes.
>>
>>So is there a way to get the word/text that was under the mouse when it 
>>was double clicked?
> 
> 
> Yes.
> 
> The simplest way is not clientside javascript, though, 
> just HTML and serverside scripting, possibly in javascript.
> 
> Try it, and we could help if you get stuck,
> if you use serverside javascript that is, 
> otherwise ask in the appropriate NG.
> 

comp.lang.javascript ?
I have heard of serverside javascript but never really got into it.
How does one go about writing server side javascript? How would 
something server side know when a user clicks in the client?

.... This is for a online Bible and I hope to eventually link in 
Strong's Concordance to it so that readers could double click a word to 
get definitions/translations/etc..

Thanks
Mike

[toc] | [prev] | [next] | [standalone]


#15016

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-07-11 08:39 +0000
Message-ID<XnsA08D6C7BE3E0Eeejj99@194.109.133.133>
In reply to#15012
Michael Joel wrote on 11 jul 2012 in comp.lang.javascript:

> comp.lang.javascript ?

You will find javascript engines used in many other places than browsers.

> I have heard of serverside javascript but never really got into it.
> How does one go about writing server side javascript? How would 
> something server side know when a user clicks in the client?

Just type  the file.

on an ASP platform, define JS as the default and write between:


<% response.write('Hello world'); %>

or even shorthand:

<% = 'Hello world' %>

 
> .... This is for a online Bible and I hope to eventually link in 
> Strong's Concordance to it so that readers could double click a word
> to get definitions/translations/etc..

I prefer concordance with Hebrew or ECMA.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#15032

FromScott Sauyet <scott.sauyet@gmail.com>
Date2012-07-12 19:40 -0700
Message-ID<3c9e5be0-549f-4d96-b16d-133bb56bb253@i11g2000yqo.googlegroups.com>
In reply to#15012
Michael Joel wrote:
> Evertjan. wrote:
>> Try it, and we could help if you get stuck,
>> if you use serverside javascript that is,
>> otherwise ask in the appropriate NG.
>
> comp.lang.javascript ?
> I have heard of serverside javascript but never really got into it.
> How does one go about writing server side javascript?

There are many uses of Javascript on the server.  ASP [1] has had it
for years.  Node.js [2] seems to be the latest darling of the web
developer community, although some prefer Narwhal [3].  But there are
far too many implementation to keep track of.

    [1]: <http://msdn.microsoft.com/en-us/library/aa286483.aspx>
    [2]: <http://nodejs.org/>
    [3]: <https://github.com/tlrobinson/narwhal>


> How would  something server side know when a user clicks in
> the client?

It wouldn't, not until after an HTTP request, the same as with any
other server-side language.

  -- Scott

[toc] | [prev] | [next] | [standalone]


#15037

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2012-07-13 07:06 +0000
Message-ID<XnsA08F5CA7CF36Aeejj99@194.109.133.133>
In reply to#15032
Scott Sauyet wrote on 13 jul 2012 in comp.lang.javascript:

>> How would  something server side know when a user clicks in
>> the client?
> 
> It wouldn't, not until after an HTTP request, the same as with any
> other server-side language.

That's why they are called server and client.

The client initiates all actions, 
while the only duty of a server is to serve.

=================

<a href='/storeThis.asp?where=field1&value=23' 
target='myInvisibleIframe'>
Store 23 in field one</a>

<a href='/storeThis.asp?where=field2&value=stop' 
target='myInvisibleIframe'>
Store 'stop' in field two</a>

will bring the server javascript code into action defined by the serverside  
scripting, without any clientside scripting language used.

Beware of sql-injection with these examples, 
so write solid serverside code [and test for in-session].

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#15006

FromEli the Bearded <*@eli.users.panix.com>
Date2012-07-10 19:42 +0000
Message-ID<eli$1207101533@qz.little-neck.ny.us>
In reply to#15004
In comp.lang.javascript, Michael Joel  <null@void.void> wrote:
> I want to be able to get word definitions to display when a user double 
> clicks a word being displayed.

I've used sites that do this and I find it very annoying. I double
click to select words and I triple click to select a paragraphs.
Usually I do this as a visual bookmark when scrolling, but sometimes
to cut&paste. 

If you want to include a glossary for difficult words, you can just use
<a> links with title text:

 <a title="section of a document that defines words">glossary</a>

Hovering over the word shows the title text. Style as desired.

Elijah
------ 
can't think of a site offhand that still does definition thing

[toc] | [prev] | [next] | [standalone]


#15007

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-07-10 22:32 +0200
Message-ID<19461548.vUfxvZx9aS@PointedEars.de>
In reply to#15006
Eli the Bearded wrote:

> In comp.lang.javascript, Michael Joel  <null@void.void> wrote:
>> I want to be able to get word definitions to display when a user double
>> clicks a word being displayed.
> 
> I've used sites that do this and I find it very annoying. I double
> click to select words and I triple click to select a paragraphs.
> Usually I do this as a visual bookmark when scrolling, but sometimes
> to cut&paste.

It would not interfere if there was a definition mode that you need to 
enable first.

> If you want to include a glossary for difficult words, you can just use
> <a> links with title text:
> 
>  <a title="section of a document that defines words">glossary</a>

Not so.  If it is a link, use an `href' attribute.  If it is not a link, do 
not use an `a' element; use a `span' element or another inline-level element 
if it is better semantically.  All those have a `title' attribute.

However, be aware that the `title' attribute does not mean "tooltip"; it 
means "additional information" and does not prescribe a certain kind of 
display.  If you want a tooltip, use CSS; for example, my Accessible Pure 
CSS Tooltips, which can be complemented with scripting, as used on 
<http://PointedEars.de/es-matrix>.


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

[toc] | [prev] | [next] | [standalone]


#15018

FromMartin Honnen <mahotrash@yahoo.de>
Date2012-07-11 13:08 +0200
Message-ID<4ffd5ead$0$6566$9b4e6d93@newsspool3.arcor-online.net>
In reply to#15004
Michael Joel wrote:

> So is there a way to get the word/text that was under the mouse when it
> was double clicked?


A double click selects the clicked text and you can access the 
selection, see 
http://home.arcor.de/martin.honnen/javascript/2012/test2012071101.html 
for an example. You might need to cut off a trailing space included by 
most browsers it seems.

And the example tries to cater for both the window.getSelection 
supported with Mozilla, Opera, Chrome, and IE 9 as well as 
document.selection supported in older IE versions but I haven't tested 
with older IE versions.

For a documentation see https://developer.mozilla.org/en/DOM/Selection 
and http://msdn.microsoft.com/en-us/library/ie/ms535872%28v=vs.85%29.aspx


-- 

	Martin Honnen --- MVP Data Platform Development
	http://msmvps.com/blogs/martin_honnen/

[toc] | [prev] | [next] | [standalone]


#15022

FromDr J R Stockton <reply1228@merlyn.demon.co.uk.not.invalid>
Date2012-07-11 21:15 +0100
Message-ID<YM6pagMt7d$PFwMo@invalid.uk.co.demon.merlyn.invalid>
In reply to#15004
In comp.lang.javascript message <Q5ydnay5Dr1l5mHSnZ2dnUVZ_j-
dnZ2d@earthlink.com>, Tue, 10 Jul 2012 15:01:31, Michael Joel
<null@void.void> posted:

>So is there a way to get the word/text that was under the mouse when it
>was double clicked?


My <http://www.merlyn.demon.co.uk/js-props.htm> does that; press the
Enter button, then double-click a word in the new grey area - it will be
appended to the input line.  The actual code is in
<http://www.merlyn.demon.co.uk/inc-prop.js>; just remove what you do not
need.  Note : I give special treatment to all-digit "word"s.

-- 
 (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk  Turnpike v6.05  MIME.
  Web  <http://www.merlyn.demon.co.uk/> - FAQqish topics, acronyms and links;
  Astro stuff via astron-1.htm, gravity0.htm ; quotings.htm, pascal.htm, etc.
 No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web