[Javascript] detecting an onChange event of a form object

Roger Roelofs rer at datacompusa.com
Mon Jun 30 22:32:26 CDT 2003


It looks pretty straight forward.  Here's the relavant code.  I've  
cleaned it up a bit and added some comments to make it clearer (I  
hope).  Having said that, It requires a backend application to return  
results from the dictionary lookup.  Also, I notice they are willing to  
sell you this technology.  It's not rocket science, but if you want  
help, you might want to send them an email.
---------
<SCRIPT language="JavaScript">

function display() {  //only works in ie
   if (typeof document.getSelection != "undefined"){  //the mozilla way
     var str = document.getSelection();
   }else{
     if (document.selection && document.selection.createRange) {  // the  
ie way
       var range = document.selection.createRange();
       var str = range.text;
    }
   }
   // if str is not empty & reasonably short enough do the lookup.
   if ((str != "") && (str.length < 30)) {
    var glossary = window.open("","glossary",...);  // open the window
    var doc = glossary.document;
    doc.open("text/html", "replace");  // write the document
    doc.write('<html><head><title>Active Glossary</title></head><body>');
    doc.write('<form name="form1"  
action="/support/glossary/glossary.php">');
    doc.write('<input type="hidden"  
name="lookup"></form></BODY></HTML>');
    doc.form1.lookup.value = str;  // insert the selected string
    doc.form1.submit();		// submit the form
    doc.close();
    document.selection.empty();
   }
}

if (typeof window.Event != 'undefined'){  // we're in ie
     document.captureEvents(Event.MOUSEUP);
}
document.onmouseup = display; // check every mouseup to see if text is  
selected.

</SCRIPT>


On Monday, Jun 30, 2003, at 19:06 America/Detroit, DEV wrote:

> http://www.childbirthsolutions.com/support/glossary/howto.php has a  
> pretty
> good tool called Active Glossary.  Microsoft uses it at
> http://www.microsoft.com/windows2000/en/server/iis/default.asp?url=/ 
> windows2000/en/server/iis/htm/core/iiabdsk.htm
> too.
>
> What it is that you highlight a word, on key up, it does look up.
>
> If there is anyone who'd like to hassle with it to sort this out and  
> share
> the results back with the list, go ahead.



More information about the Javascript mailing list