JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 13th, 2012, 09:25 AM
seamoon seamoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 22 seamoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 14 m 41 sec
Reputation Power: 0
Text selection disable script and Opera flaw

This script works fine on all other browsers except in Opera, if you drag mouse a little above the (starting of essay) "Evliliğe Dair" then the text can be selected. How to fix this flaw?

http://www.aymavisi.org/makale/Evli...%20Gibran).html


Code:
<script type="text/javascript">
function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
	target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
	target.style.MozUserSelect="none"
else //All other route (ie: Opera)
	target.onmousedown=function(){return false}
target.style.cursor = "default"
}
</script>



Code:
</body>
<script type="text/javascript">
disableSelection(document.body) 
</script>

<script type="text/javascript">
var somediv=document.getElementById("layer1")
disableSelection(somediv) 
</script>

Reply With Quote
  #2  
Old December 13th, 2012, 09:40 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,871 Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level)Winters User rank is General 24th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 16 h 31 m 11 sec
Reputation Power: 2569
Modern versions of IE and Opera ignore selection disabling options in both Javascript and CSS.
__________________
[PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

W3Fools - A W3Schools Intervention.

Reply With Quote
  #3  
Old December 13th, 2012, 10:17 AM
seamoon seamoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 22 seamoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 14 m 41 sec
Reputation Power: 0
Not really, if I add an another empty layer just above of the "Evliliğe Dair" then text selection completely disabled for Opera but I don't want to add such layer to my 1000+ pages.

Reply With Quote
  #4  
Old December 13th, 2012, 05:28 PM
Kravvitz's Avatar
Kravvitz Kravvitz is offline
CSS & JS/DOM Adept
Dev Shed God 30th Plane (19500 - 19999 posts)
 
Join Date: Jul 2004
Location: USA
Posts: 19,831 Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level)Kravvitz User rank is General 48th Grade (Above 100000 Reputation Level) 
Time spent in forums: 6 Months 1 Day 19 h 19 m 2 sec
Reputation Power: 4192
Being able to prevent text selection can be useful for drag-and-drop scripts, but using it to prevent copy-and-pasting of text is just user-hostile. People can often just do a "Select All" and then a "Copy" anyway. And usually they could view the page's source to access the text as well.

The web is a free (well mostly) and open medium. Get used to it.
Comments on this post
Jacques1 agrees: "The web is a free (well mostly) and open medium." Kind of sad that so many "web developers" still
haven't understood that.
__________________
Spreading knowledge, one newbie at a time. I'm available for hire at Dynamic Site Solutions.

Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

Remember people spend most of their time on other people's sites (so don't violate web design conventions).

Reply With Quote
  #5  
Old December 14th, 2012, 07:23 AM
seamoon seamoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 22 seamoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 14 m 41 sec
Reputation Power: 0
Well if you spent 7 years on a site with original content then your site content becomes just a compilation of other forums and blogs you'd think different.

Reply With Quote
  #6  
Old December 14th, 2012, 07:51 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,860 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 49 m 4 sec
Reputation Power: 813
Hi,

there is no technical way to prevent people from "stealing" your content. None.

Try to contact those websites or their hosters, try to sue them, whatever. But this JavaScript stuff will get you nowhere. Even the most retarded Internet users know how to view the page source (as Kravvitz already said). And the more intelligent ones simply disable their JavaScript or fetch the site content directly through HTTP (without any browser involved).

So forget that "copyright script". All it does is irritate and annoy legitimate users and give the bad guys a good laugh. Actually, when a website doesn't allow me to do what I want to do, I'm out and won't come back. So this script might actually make you lose users.

What you're trying to do is kind of a contradiction in terms: When you publish something, it's public. Anybody can view and use the data in any way they want.

I understand your concerns, and it really is annoying to see content pop up somewhere else. But you're fighting on the wrong end.

By the way, the script also doesn't work in Chrome. Throw it away.

Reply With Quote
  #7  
Old December 14th, 2012, 08:27 AM
seamoon seamoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 22 seamoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 14 m 41 sec
Reputation Power: 0
If I add an empty layer on the text then script works with Chrome and Opera as well.

http://www.aymavisi.org/hikaye/Anadoluda%20Bir%20Gece%20-%20Peyami%20Safa.html

Reply With Quote
  #8  
Old December 14th, 2012, 08:37 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,860 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 17 h 49 m 4 sec
Reputation Power: 813
What are you here for when you don't care what we have to say? If you want useless help for nonsense scripts from the 90s, go to w3schools.

I can still select the text by simply clicking outside of the layers. And if I couldn't, I'd hide the layers in my browser. That's two clicks. I don't even have to view the source.

Reply With Quote
  #9  
Old December 14th, 2012, 09:35 AM
seamoon seamoon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2011
Posts: 22 seamoon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 14 m 41 sec
Reputation Power: 0
Surely it's useful than what you keep saying or better than nothing. Bye.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Text selection disable script and Opera flaw

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap