[Javascript] peculiarity of onselectstart/third

David T. Lovering dlovering at gazos.com
Wed Jul 16 15:33:23 CDT 2003


Way cool!  This goes way beyond the "standard" treatment of onselectstart
given in the books.  Handling this at the event level does provide the
needed descrimination though, without the "poisoning" effect of simply
launching it with { return false; } at the document level from the very
start.  Somebody earned their browny points on this one!  Kudos to you...

-- Dave Lovering

BEKIM BACAJ wrote:
> 
> Well, you owe me this one!
> the onselectstart turned false disables all the content from being
> selected, no matter what you do after this will not help so wei will
> filter unwanted items like this:
> 
> <HTML>
>     <HEAD>
>       <TITLE> Trojani </TITLE>
>       <script language='JavaScript'>
>       <!--
> 
> function filterSelectability(){
>   var inptName=event.srcElement.name;
> //Headache! - suppressing error for "undefined" elements
>  if (typeof(inptName) == "undefined"){return false}
>   var fld=inptName.substring(0,5);
>  if(fld=='field'){return true}
>       else{return false}
>   }
>         document.onselectstart = filterSelectability;
>       // -->
>       </script>
>     </head>
>     <body>
> 
>       <form name='myBogusForm' action='javascript:void(null)'>
>         <center>
> 
>           <input name='field1' type='text' value='' size=30 ><br>
>           <input name='field2' type='text' value='' size=30 ><br>
> 
>         </center>
>       </form>
> 
>     </body>
> </html>
> 
> 
> Had some hard time with undefined items but it is solved now,
> Cheers!
> 
> 
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> Protect your PC - Click here for McAfee.com VirusScan Online
> 
>    Part 1.2    Type: Plain Text (text/plain)
>            Encoding: 7bit


More information about the Javascript mailing list