Loading gif not in center of page

Solution 1:

Do you mean to say this? Just use transform: translate(x,y). Please check the cssText if it feeds your need.

    <script>
      function ShowLoading(e) {
        var div = document.createElement("div");
        var img = document.createElement("img");
        // img.src = "loading_bar.GIF";
        div.innerHTML = "Loading...<br />";
        div.style.cssText =
          "position: fixed; top: 50%; left: 50%; z-index: 5000; width: 422px; text-align: center; background: #EDDBB0; border: 1px solid #000; transform: translate(-50%,-50%)";
        // div.appendChild(img);
        document.body.appendChild(div);
        return true;
        // These 2 lines cancel form submission, so only use if needed.
        //window.event.cancelBubble = true;
        //e.stopPropagation();
      }
      ShowLoading();
    </script>