0

On opening a dialog I want to make the rest of the body readonly/unselectable. I'm using jquery. Currently I'm using this, but it doesnt work:

<script>
$('document').ready(function() {
    $('#advertMenu').click(function() {
        $("body").attr("readonly", "readonly"); 
    });
});
</script>

After Edit

$("body").css("-moz-user-select", "-moz-none"); 
        $("body").css("-khtml-user-select", "none");
        $("body").css("-webkit-user-select", "none");
        $("body").css("-o-user-select", "none");
        $("body").css("-user-select", "none");
Jaskaran S.P
  • 1,055
  • 2
  • 14
  • 15

2 Answers2

0

Please try this

.unselectable {
    -moz-user-select: -moz-none;
    -khtml-user-select: none;
    -webkit-user-select: none;
    -o-user-select: none;
    user-select: none;
}

 $('#advertMenu').click(function() {
        $("body").addClass('unselectable'); 
 });
Anjith K P
  • 2,158
  • 27
  • 35
-1

Try this:-

         $(document).ready(function(){
             $('body').attr('unselectable', 'on')
             .css('user-select', 'none')
             .on('selectstart', false);
             });

Live Demo:http://jsfiddle.net/d48vY/

Umesh Sehta
  • 10,555
  • 5
  • 39
  • 68
  • yes it works, but the problem is all the links & from fields are still selectable. how can they be disabled as well ? – Jaskaran S.P May 20 '13 at 13:40