Link to home
Start Free TrialLog in
Avatar of dave4dl
dave4dl

asked on

How do i make text unselectable

What is the best way to make displayed text in an <a> tag or a <td> tag unselectable?

Thanks
Avatar of pvginkel
pvginkel
Flag of Netherlands image

Only works in IE:

<div unselectable="on">
foo bar foo bar foo bar foo bar<br />
foo bar foo bar foo bar foo bar<br />
foo bar foo bar foo bar foo bar<br />
</div>
Avatar of dave4dl
dave4dl

ASKER

Thanks for the response.

This doesn't work for my problem because it isn't scriptable and the html on my page is creating by client javascript using the DOM (and outerHTML is not writable for TD tags).

I tried surrounding my script-created elements with a div tag with unselectable=on but the property apparently didn't cascade to the child objects (or maybe it wasnt applied because the child objects were added after the document was loaded).

also, while not absolutely necessary, it would be better if there was a solution that works on other browsers.  This is less import than having it work on at least ONE browser though (the above solution doesn't work for my situation).

I should probably tell what my situation is (in addition to the first part of this message).  I've written some code to create a menu based on dynamic data (hence the html created with javascript) and I would like to set the menu so that users can't select it if they drag the mouse over it but they can still click on all the menu items and be taken to the appropriate page.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of pvginkel
pvginkel
Flag of Netherlands 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 dave4dl

ASKER

Thanks for your help!!

Sorry it took me so long to close this.
Does not work for firefox