在Internet Explorer中图像加载超时 [英] Image load timeout in Internet Explorer
问题描述
我有显示从使用Web服务的文件存储系统流的文档图像的内部应用程序的网页。我遇到的问题是,当用户执行他们的搜索他们可能会得到数百命中,这是我必须要显示一个大的页面上,使他们能够全部打印出来。这在Firefox正常工作,但在IE停止一段时间后,加载图像,所以我得到一百元左右显示,剩下的只是有破碎的形象符号。是否有一个设置的地方,我可以改变这个超时?
I have a page for an internal app that displays document images streamed from a document storage system using a web service. The problem I am having is that when a user does their search they may get hundreds of hits, which I have to display on one large page so they can print them all. This works fine in Firefox, but in IE it stops loading the images after a while so I get a hundred or so displayed and the rest just have the broken image symbol. Is there a setting somewhere that I can change this timeout?
推荐答案
如果问题确实是一个超时,您可能能够通过使用延迟加载的剧本,只有经过添加新的图像文件来解决它现有图像已加载。
If the issue is indeed a timeout, you might be able to work around it by using a "lazy load" script and adding new images to the document only after existing images have loaded.
有很多方法可以做到这一点,但这里有一个简单的例子我扔在一起并进行测试。取而代之的是:
There are a lot of ways to do this, but here's a simple example I threw together and tested. Instead of this:
<img src="image001.jpg" />
<img src="image002.jpg" />
<img src="image003.jpg" />
<img src="image004.jpg" />
<!-- Etc etc etc -->
您可以这样做:
<div id="imgsGoHere">
</div>
<script type="text/javascript">
function crossBrowserEventAttach(objectRef, eventName, functionRef)
{
try {
objectRef.addEventListener(eventName, functionRef, false);
}
catch(err) {
try {
objectRef.attachEvent("on" + eventName, functionRef);
}
catch(err2) {
// event attachment failed
}
}
}
function addImageToPage()
{
var newImageElement = document.createElement("img");
newImageElement.src = imageArray[nextImageNumber];
var targetElement = document.getElementById("imgsGoHere");
targetElement.appendChild(newImageElement);
nextImageNumber++;
if (nextImageNumber < imageArray.length) {
crossBrowserEventAttach(newImageElement, "load", addImageToPage);
crossBrowserEventAttach(newImageElement, "error", addImageToPage);
}
}
var nextImageNumber = 0;
var imageArray = new Array();
imageArray[imageArray.length] = "image001.jpg";
imageArray[imageArray.length] = "image002.jpg";
imageArray[imageArray.length] = "image003.jpg";
// .
// .
// .
// Snip hundreds of rows
// .
// .
// .
imageArray[imageArray.length] = "image999.jpg";
addImageToPage();
</script>
每个图像只有previous图像加载后添加到页面(或无法加载)。如果您的浏览器超时,我认为这将解决这个问题。
Each image is added to the page only after the previous image loads (or fails to load). If your browser is timing out, I think that will fix it.
当然,这个问题实际上可能不会超时,而是你正在运行内存/系统资源和IE被放弃。还是喜欢撒席说有可能是一个IE浏览器的DOM的限制。
Of course, the problem might actually not be a timeout, but rather that you're running out of memory/system resources and IE is giving up. Or there might be an IE DOM limitation like Sra said.
这篇关于在Internet Explorer中图像加载超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!