The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Disabling text selection/highlighting

4 posters

Go down

Solved Disabling text selection/highlighting

Post by teshrin June 18th 2012, 4:03 pm

Is there a way to disable text selection in Javascript/HTML to avoid copying of the text in forums? There are multiple codes in both Javascript and HTML available on the Internet, but they do not seem to work when copied to Modules >> HTML & Javascript >> HTML/Javascript subkategories. Is there a certain code that would be effective in forums' topics?


Last edited by teshrin on June 19th 2012, 4:35 pm; edited 1 time in total
avatar
teshrin
New Member

Posts : 4
Reputation : 0
Language : Estonian
Location : Tartu

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by Ryanette June 18th 2012, 10:31 pm

::selection{background:transparent;}
::-moz-selection{background:transparent;}
Ryanette
Ryanette
Forumember

Male Posts : 135
Reputation : 2
Language : English (British)
Location : England, United Kingdom

http://www.devforumz.com

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by Ryanette June 18th 2012, 11:11 pm

Rideem3 wrote:
Ryanette wrote:::selection{background:transparent;}
::-moz-selection{background:transparent;}

That won't stop it. It will simply take away the blue highlight.

Stopping it completely is impossible since there's always viewing the source and copying it from there, DOM inspection tools, and etc. Wink
Yeah, it'll make it look like it's not selectable Wink
Ryanette
Ryanette
Forumember

Male Posts : 135
Reputation : 2
Language : English (British)
Location : England, United Kingdom

http://www.devforumz.com

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by LGforum June 19th 2012, 12:11 am

Shouldn't this work:

Code:

body {
  -moz-user-select: -moz-none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

If not, then this:
Code:

* {
  -moz-user-select: -moz-none;
  -khtml-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

(This is CSS by the way, not Javascript, and so goes in the CSS)
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by teshrin June 19th 2012, 3:35 pm

Alright. This CSS code works in Mozilla, Chrome, Safari and Songbird, but not in IE or Opera. Are there any additional codes to disable highlighting in those two?
avatar
teshrin
New Member

Posts : 4
Reputation : 0
Language : Estonian
Location : Tartu

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by LGforum June 19th 2012, 3:39 pm

It will prevent it in IE9 because of this property: -ms-user-select: none;
I believe that's a valid property as of IE9. Though you may need to perform this edit so your forumotion board doesn't prevent the IE9 rendering engine from being used: http://www.avacweb.com/t294-allow-border-radius-in-ie9

I'm not sure if Opera supports the user-select property. But you can try by adding the property: -o-user-select: none
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by teshrin June 19th 2012, 4:35 pm

Opera apparently doesn't support it because I added this property earlier as well but it didn't work. Also, I performed the IE edit, but as I have IE8, it might not show. Then again, IE is so unpopular that I believe people usually go for Mozilla or better.

Anyway, thank you! You helped a lot! Smile

EDIT: Alright, I just learned that highlighting is disabled in IE9, so the edit was successful.
avatar
teshrin
New Member

Posts : 4
Reputation : 0
Language : Estonian
Location : Tartu

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by Sanket June 19th 2012, 6:54 pm

Topic Solved & Locked
Sanket
Sanket
ForumGuru

Male Posts : 48766
Reputation : 2830
Language : English
Location : Mumbai

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum