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 (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."

Jon was previously employed as a senior .NET developer at a very well-known Internet services company whom you're more likely than not to have directly done business with. However, this blog and all of jondavis.net have no affiliation with, and are not representative of, his former employer in any way.

Contact Me 


Tag cloud

Calendar

<<  August 2020  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

View posts in large calendar

RecentPosts