简体   繁体   中英

Disable checkboxes not working in Internet explorer but works in chrome

I want to disable checkboxes in a datatable for few users, when i open my link through IE, those users can make changes to checkboxes whereas I dont see any issue in Chrome, it works as expected. Users are restricted from checking those boxes.

Below is the code

if(getURLParam("filetype"))
    {
        $(".disablePage").addClass('disabledbutton');
        $("#picklistBody").addClass('disabledbutton');
        $("#STATUSDIVID").removeAttr('class').addClass('div-warning').html("This page is view only!");  
    }   

Can you please let me know how could I restrict users from checking the boxes when they open the Link in IE.

If you just want to disable users to not be able to check the checkboxes, use attr or prop to disable them depending on Jquery version:

$("input[type=checkbox]").prop("disabled", true);

This will find all checkboxes on the page and disable them. You may have to modify it slightly if you only want certain checkboxes disabled.

Also I see that you are adding a disabled class for buttons when they are not allowed to be used. This will still allow the user to click the button, though they are styled like they are unclickable. Make sure to disable the button as well:

$(".disablePage").addClass('disabledbutton').prop("disabled", true);
$("#picklistBody").addClass('disabledbutton').prop("disabled", true);

Edit: Full code

if(getURLParam("filetype")) {
        // Disable the buttons
        $(".disablePage").addClass('disabledbutton').prop("disabled", true);
        $("#picklistBody").addClass('disabledbutton').prop("disabled", true);

        // Disable all checkboxes
        $("input[type=checkbox]").prop("disabled", true);

        $("#STATUSDIVID").removeAttr('class').addClass('div-warning').html("This page is view only!");  
    }   

You mentioned in a comment that you're trying to disable your checkboxes with CSS.

Most versions of IE don't support the pointer-events CSS attribute. For a long time it was only supported by Chrome. For a while they were considering deprecating it as well. They also have spotty coverage on mobile.

In other words, don't rely on pointer events; Use HTML disabled properties instead.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM