CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Text selection disable & Opera Browser (http://www.codingforums.com/showthread.php?t=283902)

tunayx 12-10-2012 03:23 PM

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.

AndrewGSW 12-10-2012 04:37 PM

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.

tunayx 12-10-2012 04:47 PM

Sorry, I reupload the example page. You can now see the correct page.

Btw you can choose install Opera as portable in install options.

felgall 12-10-2012 05:59 PM

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.

AndrewGSW 12-10-2012 06:02 PM

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.

tunayx 12-10-2012 06:58 PM

Could you explain the third field please?

AndrewGSW 12-10-2012 07:40 PM

1 Attachment(s)
Screenshot attached re. third.

tunayx 12-10-2012 08:20 PM

But how to fix it, in my web page there's no such line?

AndrewGSW 12-10-2012 08:32 PM

Quote:

Originally Posted by tunayx (Post 1298843)
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..

tunayx 12-10-2012 09:28 PM

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


All times are GMT +1. The time now is 11:37 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.