Link to home
Start Free TrialLog in
Avatar of yes4me
yes4me

asked on

Make it so that the user cannot select the text for NS4.79

If you run this code under IE5.5 or NS6, you will not be able to select the text displayed "Cannot select text". However you can select the text in NS4.79. Can someone modify this code so that it works for all three browsers? Thanks in advance.


<HTML><head>
<script language="JavaScript1.2">
     //if IE4+
     document.onselectstart=new Function ("return false")

     //if NS6
     function disableselect(e)
     {
          return false
     }

     function reEnable()
     {
          return true
     }
     if (window.sidebar)
     {
          document.onmousedown=disableselect
          document.onclick=reEnable
     }
</script>
</head><body>
     Cannot select text
</body></html>
Avatar of third
third
Flag of Philippines image


With IE4+ the following works:
  if (document.all)
    document.onselectstart =
      function () { return false; };
With NN4 the following works
  if (document.layers) {
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown =
      function (evt) {
        return false;
      };
  }
but note that it cancels every mousedown action which will prevent
other user action (link click, right click etc) as well.

For NN6
  document.onmousedown =
    function () { return false; };
disables text selection.


http://www.faqts.com/knowledge_base/view.phtml/aid/1891/fid/145

Can you make the text a graphic?
...like the ones that are surrounding this current page?
Avatar of fritz_the_blank
On any control that I don't want selected or modified, I do the following:

<input type=text onFocus="javascript:blur()">

I am guessing that this is not what you're looking for, however.

Fritz the Blank
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of yes4me
yes4me

ASKER

I guess this is not possible to do in NS4.75

Thanks you to acperkins for reminding me to close this outdated post. Thanks you all for trying to answer.