开发者

How to check browser state whether it is busy or not?

I am having query regarding checking the browser state........

for e开发者_运维技巧xample i am uploading some data and i am trying to show the progress bar in which i need to check the browser state.

Like if browser busy will continue showing progress.

I am using only javascript and HTML


If you're uploading some data using an xmlhttprequest you can set the state as Busy when you start sending your data and set the state as Done in the callback function that fires when the xmlHttpRequest is finished.

[EDIT] a neater example

(function scope(){
  var req = new XMLHttpRequest();
  req.open('POST', 'http://example.org/upload', true);
  req.onreadystatechange = function () {
    stopShowingProgressBar();
  };
  startShowingProgressBar;
  req.send(null);
})();

You should also check out jquery. It has global ajax events. You can register functions on AjaxStart and AjaxStop to set the Busy and Done variable

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜