Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Disable Text Selection - Script
Old 06-22-2010, 10:28 PM Disable Text Selection - Script
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Hey guys,

I've seen this come up quite a bit, and I thought I'd post this here to help all of you.

To disable text selection:
Simply add
Code:
<body onselectstart="return false">
to your page. That's it. Simple as that.

Problem with this code
Crafty users can still right-click - view source, then copy it out from there. Also if they have Javascript disabled, they can get around it. You can't disable right click, and it's pointless because they can just go to the main menu and click 'View Source' from there

Hope this helps you in any way possible from the dumber content thieves
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-23-2010, 07:32 AM Re: Disable Text Selection - Script
Extreme Talker

Posts: 246
Trades: 0
Also, as far as I can tell this is an IE specific event which means it won't work in any other browser. Not to mention this is absolutely pointless to do. If you don't want your content to be copied, don't put it up on the internet or use Silverlight or Flash (which can only make it harder to copy, not impossible).
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 06-23-2010, 10:05 AM Re: Disable Text Selection - Script
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Nope, it works on all browsers.

And I didn't say this wasn't stupid. It is.

This COULD be useful for a drag n' drop script, where you select text while you're dragging a box.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 06-23-2010, 10:45 AM Re: Disable Text Selection - Script
Extreme Talker

Posts: 246
Trades: 0
If you put the following code into an html file you will notice that it works in IE (also works in chrome) but not FF (I tested against 3.6.3). So as I said, it won't work in FireFox.

<html>
<head>
</head>
<body onselectstart="alert();">

This is some text I'm trying to copy.

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
Reply With Quote
View Public Profile
 
Old 06-23-2010, 10:46 AM Re: Disable Text Selection - Script
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Ah, I never tested it in FF :O Right?

For some strange reason I develop in Chrome, which is stupid because it 'renders' javascript very stupidly
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Disable Text Selection - Script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15109 seconds with 12 queries