SitePoint Sponsor |
|
User Tag List
Results 1 to 22 of 22
Thread: Howd they do this???
-
May 10, 2001, 00:16 #1
- Join Date
- Mar 2001
- Location
- Panhandle of Florida (White Sand/Brown Skin)
- Posts
- 147
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
go to this page
http://www.emedicine.com/emerg/topic470.htm
now highlight a word in one of the paragraphs and watch what happens...
Can someone explain how this is done to me?
thanks!
-
May 10, 2001, 00:40 #2
- Join Date
- Apr 2000
- Location
- Melbourne
- Posts
- 832
- Mentioned
- 4 Post(s)
- Tagged
- 0 Thread(s)
It's awesome.
It has to be a service that Merrian Webster are marketing. Very clever. I'm going to research it a bit. Could be quite useful for SitePoint.
You seem to just add this script to your page 'http://www.emedicine.com/medlook.js' and that selects and sends the text to a CGI script at M-W, which sends back the result.
Nice.
-
May 10, 2001, 02:11 #3
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, I know little about JavaScript but this is awesome. But I can't for the life of me work out where the selection event is handled. I can see that function display(e) is the driving function that makes everything happen - so this is the function that would need to be triggered by an event handler. But where is the event being handled. Wow!?!
-
May 10, 2001, 02:24 #4
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Amazing indeed! WOW
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
May 10, 2001, 04:55 #5
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
It might help if this thread was moved to the Client Side Scripting forum
-
May 10, 2001, 06:20 #6
- Join Date
- Jan 2001
- Location
- Milton Keynes, UK
- Posts
- 1,011
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
But where is the event being handled.
Pretty cool stuff.
-
May 10, 2001, 07:09 #7
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
This code is copied for fair use for the purpose of critique:
Code:// Trigger.js 2.0 if (window.Event) document.captureEvents(Event.MOUSEUP); document.onmouseup = display;
-
May 10, 2001, 07:11 #8
- Join Date
- Aug 2000
- Location
- Thailand
- Posts
- 4,810
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Pile of pooh !
Didn't work in Opera
H~The Artist Latterly Known as Crazy Hamster~
922ee590a26bd62eb9b33cf2877a00df
Currently delving into Django, GIT & CentOS
-
May 10, 2001, 08:16 #9
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by freakysid
MOUSUP event doesn't get handled before the page has fully loaded?"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
May 10, 2001, 10:03 #10
-
May 10, 2001, 10:26 #11
- Join Date
- Mar 2001
- Location
- Panhandle of Florida (White Sand/Brown Skin)
- Posts
- 147
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
well its awesome as hell...
And NBCi.com thought they were revolutionizing the internet hah!
this page hasnt been edited since 2000/09/08 ROFL
that means this whole "any word, click it, get instant information" has been out long before NBCi "invented" it
Another funny thing is that the page doesnt even tell you about this dictionary program... I just happened to highlight something to copy and paste it into a search engine heh
-
May 10, 2001, 12:27 #12
- Join Date
- Feb 2001
- Location
- Dùn Éideann, Alba
- Posts
- 72
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I'm trusting every1 here is using (Opera-fiends apart) IE5+, since I reckon this will only work in W3C-DOM browsers such as IE5+ or NS6+. Certainly, highlighting a piece of text uses (i believe, though somebody might want to correct me on this) the text-range method, which is unavailable to Navigator users and most likely IE4 users too. (Opera users can go jump, since Opera (despite what Opera may say) has poor JS support.) Nonetheless, the website is awesome.
If any1 wants to learn how to do this sort of thing, then go to msdn.microsoft.com/webworkshop
-
May 10, 2001, 17:11 #13
-
May 10, 2001, 17:49 #14
- Join Date
- Jul 1999
- Location
- Chicago
- Posts
- 2,629
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey, what does this do exactly? When I select a word or two, it says in the status bar "You have selected a large amount of text. This text is copyrighted by eMedicine, Inc." and then freezes my IE. I'm using IE 5.01 on Win2k.
-
May 10, 2001, 18:07 #15
-
May 10, 2001, 18:10 #16
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by Scot-Bot
I'm trusting every1 here is using (Opera-fiends apart) IE5+, since I reckon this will only work in W3C-DOM browsers such as IE5+ or NS6+. Certainly, highlighting a piece of text uses (i believe, though somebody might want to correct me on this) the text-range method, which is unavailable to Navigator users and most likely IE4 users too. (Opera users can go jump, since Opera (despite what Opera may say) has poor JS support.) Nonetheless, the website is awesome.
If any1 wants to learn how to do this sort of thing, then go to msdn.microsoft.com/webworkshop
http://developer.netscape.com/docs/t...enthandler.htm
As you can see from the code I cut-and-pasted from the site in my last post, the event being handled is the onMouseUp event.
From reading over the two javascript files used in that page the gist of the logic appears to be this:
When a onMouseUp event is triggered call function display()
Function display() uses getSelection method (from memory - or something similar - like I said I'm not very well versed with JavaScript) to return the currently selected text in the document. It then uses a couple of utility functions to trim the selection string. If the string is empty the function exits. If the string is a hyperlink it allows the hyperlink event to occur. Otherwise another function popup() is called and passed the string. popup() creates a popup window and calls a url which includes the string. The resulting document is generated from a CGI which is essentially a dictionary and reference for the search string.
That's mumbled off the top of my head from my memory of looking over the code last night.Last edited by freakysid; May 10, 2001 at 18:19.
-
May 10, 2001, 18:38 #17
- Join Date
- Jul 2000
- Location
- 80,000 feet below the surface
- Posts
- 1,442
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Event handlers are reasonably well implemented in version 4 browsers (particularly mouse-up/down)..... You may get sketchy results in NN4 but I know for a fact that it should be right in IE4.
Very, very cool technique.....
-
May 11, 2001, 05:23 #18
- Join Date
- Feb 2001
- Location
- Dùn Éideann, Alba
- Posts
- 72
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I just checked out getSelection() and it appears to be Netscape only.
There must have been another IE method that achieves the same thing, so does any1 know what it is?
-
May 11, 2001, 11:52 #19
- Join Date
- Jun 2000
- Location
- Summerland, BC, Canada.
- Posts
- 226
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally posted by qslack
Hey, what does this do exactly? When I select a word or two, it says in the status bar "You have selected a large amount of text. This text is copyrighted by eMedicine, Inc." and then freezes my IE. I'm using IE 5.01 on Win2k.Ed Rands
-
May 13, 2001, 11:05 #20
- Join Date
- Jun 2000
- Location
- Sydney, Australia
- Posts
- 3,798
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Scot-bot, have you looked at the code?
The code below is from http://www.emedicine.com/medlook.js and is shown here for fair use for the purpose of review and critique:
Code:function display(e) { if (document.getSelection) { var str = document.getSelection(); } else if (document.selection && document.selection.createRange) { var range = document.selection.createRange(); var str = range.text; } else { var str = ""; alert("Sorry, Medical Dictionary Lookup is not possible with your browser. Please upgrade to Netscape's or Microsoft's latest browser."); return; }
-
May 13, 2001, 18:59 #21
- Join Date
- Jul 2000
- Location
- Singapore
- Posts
- 2,103
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks for the link freakysid...i guess you did alot of research into this?
"Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world."
-- Albert Einstein
-
May 14, 2001, 01:11 #22
- Join Date
- Feb 2001
- Location
- Dùn Éideann, Alba
- Posts
- 72
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Thx, Freaky, I thought the MS way might have had something to do with text-ranges.
Bookmarks