How can I disable an entire HTML page on an event like in the case of JavaScript alert?

后端 未结 5 2015
南笙
南笙 2021-01-13 05:08

I am developing a web page in JSP/HTML in which I have to disable/ \'gray screen\' an entire web page on a button click event so that an end user can\'t access the other ele

相关标签:
5条回答
  • 2021-01-13 05:15

    If you can use JQuery, and need some user input on top the gray area, try JQUery UI Dialog, and set it as modal

    0 讨论(0)
  • 2021-01-13 05:19

    The basic technique for this is to add a 100% width and height div on top of everything.

    $('body').append('<div class="cover"/>').css({
        position: 'absolute',
        height: '100%',
        width: '100%',
        zIndex: '999'
    });
    

    Then make your modal window z-index: 1000.

    0 讨论(0)
  • 2021-01-13 05:23

    CSS:

    #cover {
       position: absolute;
       top: 0;
       left: 0;
       right: 0;
       bottom: 0;
       opacity: 0.80;
       background: #aaa;
       z-index: 10;
       display: none;
    }
    

    HTML :

    <body>
    <div id="wrap">
     // your normal contents here
    </div>
    <div id="cover"> </div>
    </body>
    

    jquery :

    //trigger on whatever event required.
    $("#cover").fadeIn(100);
    alert("something");
    $("#cover").fadeOut(100); //after done.
    
    0 讨论(0)
  • 2021-01-13 05:27

    There are may ways to achieve this.. but the simplest one which i came across is to use div tag to cover the page and then remove it when event is complete

    $('body').append('<div id="over" style="position: absolute;top:0;left:0;width: 100%;height:100%;z-index:2;opacity:0.4;filter: alpha(opacity = 50)"></div>');
    

    This will add a div tag to whole body.At the end of function include this

    $("#over").remove();
    
    0 讨论(0)
  • 2021-01-13 05:30

    You may use jQuery BlockUI Plugin.

    It is simple.

    0 讨论(0)
提交回复
热议问题