The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Disabling text selection/highlighting

View previous topic View next topic Go down

Solved Disabling text selection/highlighting

Post by teshrin on 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

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 on June 18th 2012, 10:31 pm

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

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 on 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
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 on 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
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by teshrin on 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?

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 on 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
Hyperactive

Male Posts : 2254
Reputation : 254
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Solved Re: Disabling text selection/highlighting

Post by teshrin on 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.

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 on June 19th 2012, 6:54 pm

Topic Solved & Locked

Sanket
ForumGuru

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

http://webartzforum.com

Back to top Go down

View previous topic View next topic Back to top


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