Friday, November 20, 2009

What is the non-IE equivalent for the "unselectable" property in html?

Is there another property? or is there a javascript that i can use? if there is, please point me to one.



What is the non-IE equivalent for the "unselectable" property in html?windows live





Well this is , as you say , IE-specific.



This varies from browser to browser :



Firefox equivalent is a style with



{-moz-user-focus: ignore; -moz-user-input: disabled; -moz-user-select: none}



Safari:



{-khtml-user-select: none}



Opera:



{-o-user-select:none}



Actually I came across this cross-browser javascript :



document.onselectstart=new Function('return false');



function ds(e){return false;}



function ra(){return true;}



document.onmousedown=ds;



document.onclick=ra;



You could apply this to elements also.



Now the source for this code is:



http://www.felgall.com/jstip35.htm



and the warning is appropriate - if you're trying to apply this to a document it won't stop people from viewing source which is exactly what I did to copy and paste this code...



In addition, people could simply switch javascript off, so this is really only a useful property on individual elements.

No comments:

Post a Comment

 
loan