LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[CLUG] Javascript

[CLUG] Javascript

adam beecher lists at beecher.net
Tue Jun 8 23:46:17 IST 2004


Hi Peter,

> I know this is OT, but is there a Javascript expert out there?
>
Well, I'm not one anyway, so this is just imho...

> I need to know if it is possible to write a JS function which will
> send a user-highlighted text string from a Web page as the argument
> of a script URL. That is, the user double-clicks an arbitrary word
> (not a link) and a menu drops down out of nowhere and the user
> clicks 'Send' and the JS invokes a new page to
> http://blah/cgi-bin/foo?text=thestring
>
I think the answer is "yes and no", or more accurately "yes, but only with
certain browsers, and it would be ki-hinda tricky". (I just watched
Scrubs, sorry Janet.)

In /theory/, you're supposed to be able to drill right down to the
sedimentary posterior of a document with the DOM (Document Object Model),
so in /theory/ it should be possible to use an event handler (onClick,
onMouseDown, etc) to discover where you are in the DOM, convert the
relevant element into a string, and then the rest would be easy-peasy.
However I don't know how to do that; and neither does Internet Explorer,
so if the function had to be cross-browser, you'd need to delve into the
pretty world of MSDN.

Now if each word had an individual identifier (<span
id="word3">word3</span>) it would be way easier, but obviously that would
make your load time a /wee/ bit heavier, and sure and begorrah if you're
going to do that, you might as well hyperlink everything anyway.

Have a look through a few of these for a bit more info on DOM granularity
(word of the month), particularly the one on the Mozilla site about
halfway down and the one with W3C in the title towards the bottom.

http://www.google.com/search?ie=UTF-8&oe=UTF-8&q=dom+word+click

HTH,
adam



More information about the Cork mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell