locked
Data Processing RRS feed

  • Question

  • User-1499457942 posted

    hi

      I have below code and i want that it should appear in centre of Content Page.

    <script type="text/javascript">
             function ShowProgress() {
                 setTimeout(function () {
                     var modal = $('<div />');
                     modal.addClass("modal");
                     $('body').append(modal);
                     var loading = $(".loading");
                     loading.show();
                     var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
                     var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
                     loading.css({ top: top, left: left });
                 }, 200);
             }
             $("body").on("click", "[id*=btnload]", function () {
                 ShProgress();
             });
        </script>

    Thanks

    Friday, August 31, 2018 11:51 AM

All replies

  • User753101303 posted

    Hi,

    Typo on ShowProgress plus you are working on loading rarher than on modal. You want perhaps :

     var top = Math.max($(window).height() / 2 - modal.height() / 2, 0);
                    
    var left = Math.max($(window).width() / 2 - modal.width() / 2, 0);
                     modal
    .css({ top: top, left: left });

    Maybe CSS issues. Generally spoekaing you should use here F12 Console and F12 Elements to spot JavaScript errrors and see which styles are applied (you can even change them to try things)

    I noticed this loading vs modal stuff. You don't want loading to be inside modal ? It might make sense to process all the same way (ie either it"s part of the page or it is created programmatically)

    Friday, August 31, 2018 5:08 PM