Disable Text Selection In An HTML Document

by Jon Davis 12. November 2008 15:14

I just stumbled upon this. For months I've been wondering why it is that the nature of web browsers is such that if you're building a RIA where text selection would be inappropriate, such as in client-side "widgets" and "controls" where text appears as a label or text over an image to appear as a button, etc, but is rendered using HTML just the same, you cannot disable the user's ability to click-and-drag and thereby highlight text, creating a selection. This was partly disappointing for security reasons--disabling selection makes it more difficult to copy things that shouldn't be copied--and it was partly for UIX (user interface / experience) reasons--hiding from the user the obviousness that this is just a bunch of DHTML tricks and not a natively running app. I've always figured it was not possible in HTML to disable the user's ability to select text on the document. 

I was wrong! There's an old hat trick that's been around for quite a while. It's documented here:

http://support.microsoft.com/kb/318086

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Web Development

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading




 

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Jon Davis Jon Davis (aka "stimpy77") has been a programmer, developer, and consultant for web and Windows software solutions professionally since 1997, with experience ranging from OS and hardware support to DHTML programming to IIS/ASP web apps to Java network programming to Visual Basic applications to C# desktop apps.
 
Software in all forms is also his sole hobby, whether playing PC games or tinkering with programming them. "I was playing Defender on the Commodore 64," he reminisces, "when I decided at the age of 12 or so that I want to be a computer programmer when I grow up." 

Amazon Collection

Most Recent of Many Library Investments

Tag cloud

Calendar

<<  January 2009  >>
MoTuWeThFrSaSu
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

View posts in large calendar