简体   繁体   English

为什么Internet Explorer(或Chrome)不显示我的“正在加载...” gif,而Firefox却显示?

[英]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.

相关问题 为什么我的代码在Firefox中可以,但在Chrome和Internet Explorer 8中却不能? - Why is my code OK in Firefox, but not in Chrome and Internet Explorer 8? 为什么这在fireFox中有效,但在Chrome或Internet Explorer 9中却无效? - Why is this working in fireFox but not in Chrome or Internet Explorer 9? Firefox不会显示我添加的jquery元素,但Chrome会显示 - Firefox won't display my jquery added element, but Chrome will 为什么.filter()在Internet Explorer 8中不起作用? - Why won't .filter() work in Internet Explorer 8? 为什么我的代码在Chrome / Safari中完全兼容,在FireFox中完全兼容,而在Internet Explorer 8中却完全不兼容? - Why is my code fully compatible in Chrome/Safari, somewhat in FireFox, but hardly at all in Internet Explorer 8? 为什么基于setTimeout的代码不能在Firefox中以很小的超时时间运行(在Internet Explorer / Chrome中运行)? - Why doesn't this setTimeout-based code work in Firefox with a small timeout (works in Internet Explorer/Chrome)? 提交按钮不适用于Chrome或Firefox,但适用于Internet Explorer - The Submit Button doesn't work in Chrome or Firefox, but Works in Internet Explorer 为什么我的AJAX函数不能正确填充Internet Explorer中的下拉列表? - Why won't my AJAX function correctly populate a drop-down list in Internet Explorer? 为什么我的联系表格不起作用? loading.gif卡住了,什么也没发生 - Why won't my contact form work? the loading.gif is stuck and nothing happens 如果显示:无,Internet Explorer 将不会触发点击功能; - Internet Explorer won't trigger click function if display: none;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM