Stop text selection from going outside a div - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Div

Description

Stop text selection from going outside a div

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>No Select!</title> 
      <script>
            window.onload = function() {
                document.onselectstart = function() {return false;} // ie
                document.onmousedown = function() {return false;} // mozilla
            }//from  ww  w.ja  v a  2  s.co  m
        
      </script> 
   </head> 
   <body>
       Select me!  
       <p>this is a test</p>
   </body>
</html>

Related Tutorials