/    Sign up×
Community /Pin to ProfileBookmark

Is it possible to make a text node not selectable?

Hello fellow forumers,

I have a form that has some text in it that the user might think is editable, however it is not. It is placed in a field that looks like a text input, but it is not an input field. A problem occurs when the user thinks its a text field, selects the text (because the browser allows them too) and they press the back button. The user expects to see the text disappear, however the browser’s back function is initiated, taking the user to his/her previous page. This can be potentially annoying to the user.

Im wondering if this can be avoided, i tried a onclick=”this.blur()” on the element containing the text, but it didn’t work, then I tried onclick=”this.textNode.blur()” and onclick=”this.childNode.blur()”, but that didn’t work either.

Anyone have any suggestions?

Thanks,
db

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@JMRKERMar 23.2007 — Why not make the text READONLY ?
Copy linkTweet thisAlerts:
@mrhooMar 23.2007 — It is placed in a field that looks like a text input, but it is not an input field[/QUOTE]
You could make the field a readonly input field and capture the onselect events, or you could change the design so that it no longer looks like an input field. I'd go for the second option.
Copy linkTweet thisAlerts:
@decibelauthorMar 23.2007 — Sorry guys, but these suggestions cannot be implemented. The text isn't in an input field, so readonly is not an attribute of the containing element (td, div, etc).

The design is final, the look is how the client designed it, it is not changeable

Any other suggestions?
Copy linkTweet thisAlerts:
@TheBearMayMar 23.2007 — Depending on the setup you might be able place a transparent div over it.
Copy linkTweet thisAlerts:
@decibelauthorMar 23.2007 — That is a great idea... Ive done it before to block other things, and I forgot about it, guess I shouldnt smoke so much weed...

Thanks TheBearMay!
×

Success!

Help @decibel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...