0

我必须自定义dwr.util.useLoadingMessage(),现在它以红色背景出现在右上角。现在我必须将其更改为屏幕中间。

我已经用谷歌搜索了它,但无法获得确切的解决方案,谢谢。

4

1 回答 1

0

我已经像这样定制了它。下载并将dwr util.js包含在项目中并像这样修改loadingMessage

dwr.util.useLoadingMessage = function(message) {
  var loadingMessage;
  if (message) loadingMessage = message;
  else loadingMessage = "Loading";
  dwr.engine.setPreHook(function() {
    var disabledZone = dwr.util.byId('disabledZone');
    if (!disabledZone) {
      disabledZone = document.createElement('div');
      disabledZone.setAttribute('id', 'disabledZone');
      disabledZone.style.position = "absolute";
      disabledZone.style.zIndex = "1005";
      disabledZone.style.left = "0px";
      disabledZone.style.top = "0px";
      disabledZone.style.width = "100%";
      disabledZone.style.height = "100%";
      // IE need a background color to block click. Use an invisible background.
      if (window.ActiveXObject) {
        disabledZone.style.background = "white";
        disabledZone.style.filter = "alpha(opacity=0)";
      }
      document.body.appendChild(disabledZone);
      var messageZone = document.createElement('div');
      messageZone.setAttribute('id', 'messageZone');
      messageZone.style.position = "absolute";
      messageZone.style.top = "350px";
      messageZone.style.right = "600px";
      messageZone.style.background = "red";
      messageZone.style.color = "white";
      messageZone.style.fontFamily = "Arial,Helvetica,sans-serif";
      messageZone.style.padding = "4px";
      messageZone.style.zIndex = "1005";
      document.body.appendChild(messageZone);
      var text = document.createTextNode(loadingMessage);
      messageZone.appendChild(text);
      dwr.util._disabledZoneUseCount = 1;
    }
    else {
      dwr.util.byId('messageZone').innerHTML = loadingMessage;
      disabledZone.style.visibility = 'visible';
      dwr.util._disabledZoneUseCount++;
      dwr.util.byId('messageZone').style.visibility = 'visible';
    }
  });
  dwr.engine.setPostHook(function() {
    dwr.util._disabledZoneUseCount--;
    if (dwr.util._disabledZoneUseCount == 0) {
      dwr.util.byId('disabledZone').style.visibility = 'hidden';
      dwr.util.byId('messageZone').style.visibility = 'hidden';
    }
  });
};
于 2012-08-19T19:57:16.657 回答