[英]Why won't Internet Explorer (or Chrome) display my 'Loading…' gif but Firefox will?
I have a page that fires several xmlHttp requests (synchronous, plain-vanilla javascript, I'd love to be using jquery thanks for mentioning that). 我有一个页面会触发几个xmlHttp请求(同步,纯香草javascript,我很乐意使用jquery,感谢您提到)。
I'm hiding/showing a div with a loading image based on starting/stopping the related javascript functions (at times I have a series of 3 xmlhttp request spawning functions nested). 我基于启动/停止相关的javascript函数来隐藏/显示带有加载图像的div(有时我嵌套了一系列3个xmlhttp请求生成函数)。
div = document.getElementById("loadingdiv");
if(div) {
if(stillLoading) {
div.style.visibility='visible';
div.style.display='';
} else {
div.style.visibility='hidden';
div.style.display='none';
}
}
In Firefox this seems to work fine. 在Firefox中,这似乎工作正常。 The div displays and shows the gif for the required processing. div显示并显示所需处理的gif。 In IE/Chrome however I get no such feedback. 在IE / Chrome中,我没有得到任何反馈。 I am only able to prove that the div/image will even display by putting alert() methods in place with I call the above code, this stops the process and seems to give the browsers in question the window they need to render the dom change. 我只能通过使用上面的代码将alert()方法放在适当的位置来证明div / image甚至可以显示,这将停止该过程,并且似乎为有问题的浏览器提供了呈现dom变化所需的窗口。
I want IE/Chrome to work like it works in Firefox. 我希望IE / Chrome能够像在Firefox中一样工作。 What gives? 是什么赋予了?
如果xmlhttprequests不是异步的,则您会发现IE至少不会重写UI,直到它们完成为止(尽管未在Chome中进行测试),但我遇到了与非异步$ .ajax jquery请求相同的问题。
I realize you're not asking about jQuery but you might consider using jQuery to show/hide your div for easier cross browser compatibility. 我知道您不是在问jQuery,但您可能会考虑使用jQuery显示/隐藏div,以便更轻松地跨浏览器兼容。
http://api.jquery.com/show/ http://api.jquery.com/show/
http://api.jquery.com/hide/ http://api.jquery.com/hide/
Here's a helpful tutorial: 这是一个有用的教程:
http://www.learningjquery.com/2006/09/slicker-show-and-hide http://www.learningjquery.com/2006/09/slicker-show-and-hide
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.