[Laszlo-dev] more ideas for unselectable text

Henry Minsky henry.minsky at gmail.com
Thu Aug 17 18:57:14 EDT 2006


I want to make a table where the text in the table rows is not selectable.
*Find A Job or Post a Job Opening Click Here <http://tek-tips.4jobs.com/>.*
  BillyRayPreachersSon<http://www.tek-tips.com/userinfo.cfm?member=BillyRayPreachersSon>(Programmer)
30
Jan 06 18:44
 You will have to use several methods to get something that works
cross-browser. I use this combination of
CSS<http://www.tek-tips.com/viewthread.cfm?qid=1184318&page=1#>and
JavaScript. For the CSS part, assign the class "unselectable" to the
element:

CODE <http://www.tek-tips.com/viewthread.cfm?qid=1184318&page=1#>.unselectable
{
   -moz-user-select: none;
   -khtml-user-select: none;
   user-select: none;
}

and then using JS, add an onselectstart handler to it:

CODEyourEl.onselectstart = function() { return(false); };

You could also use behaviours to sort out IE, instead of that JavaScript:

CODE.unselectable {
   behavior: url(ieUserSelectFix.htc);
}

and then create this file, "ieUserSelectFix.htc":

CODE<public:component lightweight="true">

    <public:attach event="ondocumentready" onevent="stopSelection()" />

    <script type="text/javascript">
    <!--
        function stopSelection() {
            element.onselectstart = function() { return(false); };
            element.setAttribute('unselectable', 'on', 0);
        }
    //-->
    </script>
</public:component>


-- 
Henry Minsky
Software Architect
hminsky at laszlosystems.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.openlaszlo.org/pipermail/laszlo-dev/attachments/20060817/4b8e3385/attachment.html


More information about the Laszlo-dev mailing list