views:

235

answers:

1

I need to prevent users from selecting elements in my web app UI, except for text in input fields and textareas. For Firefox, the technique seems to be to use this css:

* { -moz-user-select: none; }

And that works well enough (tested Firefox 3.5.2), except that you cannot then select within input fields or textareas.

I tried dividing it into

div,td,span,img { -moz-user-select: none; }
input,textarea { -moz-user-select: text; }

however, if the input field is inside of a div, td, or span, it is not selectable. It seems that the -moz-user-select property is applied to all children as well, no matter if those children override the setting. Does anyone know a way around this aside from setting this at a far more granular (and annoying) level for specific elements?

A: 

You are fighting a lost cause. If I really want to select text from your page, or get it in some way, I will.

However, on to your question. Try adding !important to the end, so it looks like this:

div,td,span,img { -moz-user-select: none; }
input,textarea { -moz-user-select: text !important; }
phantombrain
It is not for security purposes and I don't care if the user views source or anything. It is because for some reason people keep accidentally selecting stuff and it is goofy because this is a Application and in general selecting ui elements ("buttons" formed of composite html elements for instance) feels clunky...
larson4
..oh, and more importantly, !important didn't seem to help, I did try that, should have mentioned! thank you though
larson4