Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-10-2012, 03:23 PM   PM User | #1
tunayx
New Coder

 
Join Date: Apr 2007
Posts: 57
Thanks: 3
Thanked 0 Times in 0 Posts
tunayx is an unknown quantity at this point
Text selection disable & Opera Browser

While the scipt works fine on all browsers except Opera Browser. Input fields and drop down menu becomes unclickable, how to fix it?

My example page:

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

Head:

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>

Body:


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

<script type="text/javascript">
var somediv=document.getElementById("layer1")
disableSelection(somediv) 
</script>
P.S
You can choose install Opera as portable in installation options.

Last edited by tunayx; 12-10-2012 at 04:48 PM..
tunayx is offline   Reply With Quote
Old 12-10-2012, 04:37 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
I can't see that code in the page you linked to?!

Anyway, the calls to disableSelection should not be made until the page has loaded.

Check your browser console for error messages. Mine (GC) says it couldn't load the resource http://js-kit.com/ratings.js. I don't have Opera installed currently.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 04:47 PM   PM User | #3
tunayx
New Coder

 
Join Date: Apr 2007
Posts: 57
Thanks: 3
Thanked 0 Times in 0 Posts
tunayx is an unknown quantity at this point
Sorry, I reupload the example page. You can now see the correct page.

Btw you can choose install Opera as portable in install options.
tunayx is offline   Reply With Quote
Old 12-10-2012, 05:59 PM   PM User | #4
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,455
Thanks: 0
Thanked 498 Times in 490 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
That script does nothing useful at all - all anyone need do is to turn JavaScript off for your page so that it doesn't run - something that anyone likely to want to be able to do would have an option displayed in their browser status bar to do with one click.

The only situation where anything to do with "disable" something works with JavaScript is where the visitor to your page disables the script that is blocking what they want to do.
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is online now   Reply With Quote
Old 12-10-2012, 06:02 PM   PM User | #5
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
It works for me in the recent version of Opera for Windows, but you do not have a third field in your form which causes an error.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 06:58 PM   PM User | #6
tunayx
New Coder

 
Join Date: Apr 2007
Posts: 57
Thanks: 3
Thanked 0 Times in 0 Posts
tunayx is an unknown quantity at this point
Could you explain the third field please?
tunayx is offline   Reply With Quote
Old 12-10-2012, 07:40 PM   PM User | #7
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Screenshot attached re. third.
Attached Thumbnails
Click image for larger version

Name:	opera1.jpg
Views:	18
Size:	48.5 KB
ID:	11789  
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 08:20 PM   PM User | #8
tunayx
New Coder

 
Join Date: Apr 2007
Posts: 57
Thanks: 3
Thanked 0 Times in 0 Posts
tunayx is an unknown quantity at this point
But how to fix it, in my web page there's no such line?
tunayx is offline   Reply With Quote
Old 12-10-2012, 08:32 PM   PM User | #9
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Quote:
Originally Posted by tunayx View Post
But how to fix it, in my web page there's no such line?
There is when I view the source for your page, unless you are using some kind of templating system..
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 12-10-2012, 09:28 PM   PM User | #10
tunayx
New Coder

 
Join Date: Apr 2007
Posts: 57
Thanks: 3
Thanked 0 Times in 0 Posts
tunayx is an unknown quantity at this point
I have uploaded an unprotected page below. ıt has also has the third error but input fields are working, so it's not the cause.

http://www.aymavisi.org/makale/Evlil...0Gibran)2.html
tunayx is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:30 AM.


Advertisement
Log in to turn off these ads.