[JavaScript] peculiarity of onselectstart

Chris Tifer christ at saeweb.com
Mon Jul 14 07:52:16 CDT 2003


Have you tried cancelling the bubbling of the event? If an event
fires on an element, it fires all the way up the chain. You need to
stop that event when fired by the correct element.

Chris Tifer
http://emailajoke.com

----- Original Message -----
From: "David T. Lovering" <dlovering at gazos.com>
To: <javascript at LaTech.edu>
Sent: Sunday, July 13, 2003 1:30 PM
Subject: Re: [JavaScript] peculiarity of onselectstart


>
> I just noticed in passing a peculiarity of "onselectstart" which is
somewhat annoying.
>
> What I want to be able to do is eliminate drag-selection of multiple
fields, blank form background, etc. by an
> inadvertant swipe of the mouse while the select button is depressed, while
at the same time still permitting
> drag-selection of the contents of single fields.  Ostensibly this model
should work:
>
> <html>
>     <head>
>       <title> bogus </title>
>       <script language='JavaScript'>
>       <!--
>         document.onselectstart = disableSelect;
>         function disableSelect { return false; }
>         function enableSelect { return true; }
>       // -->
>       </script>
>     </head>
>     <body>
>       <form name='myBogusForm' action='javascript:void(null)'>
>         <center>
>           <input name='field1' type='text' value='' size=30
onselectstart='enableSelect'><br>
>           <input name='field2' type='text' value='' size=30
onselectstart='enableSelect'><br>
>         </center>
>       </form>
>     </body>
>     </html>
>
> Sadly, the 'document.onselectstart' declaration appears to take precedence
over all the fields, irrespective of whether they have localized
onselectstart declarations of their own.  Yes, I've tried using straight
'return true' declarations in lieu of
> 'enableSelect' function calls.  Still no cigar.
>
> Anybody have any ideas?  This one has me stumped.
>
> -- Dave Lovering
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list